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

const IMAGES_URLS = {
  [SportTypes.BASKETBALL]: 'https://basketball.instatscout.com/images',
  [SportTypes.BOXING]: 'https://boxing.instatscout.com/images',
  [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',
}

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

export const getProfileLogo = ({
  awsInError,
  id,
  profileType,
  size = 180,
  sportType,
}: GetLogoArgs) => {
  if (awsInError) {
    return `${IMAGES_URLS[sportType]}/${PROFILE_NAMES[profileType]}/${size}/${id}.png`
  }
  return `${API_ROOT}/v1/${PROFILE_NAMES[profileType]}/${sportType}/${id}/media`
}
