import {
  SportTypes,
  ProfileTypes,
  PROFILE_NAMES,
  isProduction,
} from 'config'

import { readToken } from 'helpers'

const IMAGES_URLS = {
  [SportTypes.BASKETBALL]: 'https://basketball.instatscout.com/images',
  [SportTypes.BOXING]: '',
  [SportTypes.FOOTBALL]: 'https://instatscout.com/images',
  [SportTypes.HOCKEY]: 'https://hockey.instatscout.com/images',
  [SportTypes.HANDBALL]: 'https://handball.instatscout.com/images',
  [SportTypes.STREETBALL]: 'https://streetball.instatscout.com/images',
  [SportTypes.VOLLEYBALL]: 'https://volleyball.instatscout.com/images',
}

enum MediaType {
  cover = 'cover',
  landing = 'landing',
  landing_mobile = 'landing_mobile',
  logo = 'logo'
}

type GetLogoArgs = {
  id: number,
  isTournamentSuper?: boolean,
  profileType: ProfileTypes,
  size?: number,
  sportType: SportTypes,
}

export const getProfileLogo = ({
  id,
  isTournamentSuper,
  profileType,
  size = 180,
  sportType,
}: GetLogoArgs) => {
  switch (true) {
    case isTournamentSuper:
      return `https://cf-aws${isProduction ? '' : '-staging'}.insports.tv/media/supertournaments/${sportType}/${id}/${MediaType.logo}.jpg?access_token=${readToken()}`
    case sportType === SportTypes.BOXING:
      return `https://images.insports.tv/${sportType}/${PROFILE_NAMES[profileType]}/${id}.png`
    default:
      return `${IMAGES_URLS[sportType]}/${PROFILE_NAMES[profileType]}/${size}/${id}.png`
  }
}
