fix(#258): change link for aws logo

pull/47/head
Andrei Dekterev 3 years ago
parent 3474509c25
commit 5b9130eb11
  1. 11
      src/components/ItemInfo/ItemInfo.tsx
  2. 1
      src/config/routes.tsx
  3. 4
      src/features/FavoritesMobilePopup/components/GroupBlock/index.tsx
  4. 8
      src/features/ItemsList/index.tsx
  5. 5
      src/features/MatchPage/components/FavouriteTeam/index.tsx
  6. 3
      src/features/PreferencesPopup/components/TournamentInfo/index.tsx
  7. 8
      src/features/ProfileCard/index.tsx
  8. 49
      src/features/ProfileLogo/index.tsx
  9. 4
      src/features/TournamentList/components/CollapseTournament/index.tsx
  10. 3
      src/features/TournamentList/components/TournamentMobile/index.tsx
  11. 8
      src/features/TournamentSubtitle/index.tsx
  12. 4
      src/features/UserFavorites/TooltipBlock/index.tsx
  13. 6
      src/helpers/getProfileLogo/__tests__/index.tsx
  14. 27
      src/helpers/getProfileLogo/index.tsx
  15. 3
      src/pages/HighlightsPage/components/MatchesHighlights/index.tsx
  16. 2
      src/utilits/mirage/Mirage.tsx

@ -1,4 +1,9 @@
import { ProfileTypes, PROFILE_NAMES } from 'config' import {
ProfileTypes,
PROFILE_NAMES,
SportTypes,
URL_AWS,
} from 'config'
import { import {
ScWrapper, ScWrapper,
@ -11,6 +16,7 @@ type ItemInfoType = {
id: number, id: number,
name: string, name: string,
onClick: (val: any) => void, onClick: (val: any) => void,
sportId: SportTypes,
type: ProfileTypes, type: ProfileTypes,
} }
export const ItemInfo = ({ export const ItemInfo = ({
@ -18,10 +24,11 @@ export const ItemInfo = ({
id, id,
name, name,
onClick, onClick,
sportId,
type, type,
}: ItemInfoType) => ( }: ItemInfoType) => (
<ScWrapper onClick={onClick}> <ScWrapper onClick={onClick}>
<ScLogo src={`https://instatscout.com/images/${PROFILE_NAMES[type]}/180/${id}.png`} /> <ScLogo src={`${URL_AWS}media/${PROFILE_NAMES[type]}/${SportTypes[sportId]}/${id}/logo.jpg`} />
<ScName active={active}>{name}</ScName> <ScName active={active}>{name}</ScName>
</ScWrapper> </ScWrapper>
) )

@ -29,3 +29,4 @@ export const VIEWS_API = VIEWS_APIS[env]
export const AUTH_SERVICE = APIS[env].auth export const AUTH_SERVICE = APIS[env].auth
export const API_ROOT = APIS[env].api export const API_ROOT = APIS[env].api
export const DATA_URL = `${API_ROOT}/data` export const DATA_URL = `${API_ROOT}/data`
export const URL_AWS = 'https://cf-aws.insports.tv'

@ -2,6 +2,8 @@ import { useState } from 'react'
import map from 'lodash/map' import map from 'lodash/map'
import { URL_AWS } from 'config'
import type { UserFavorites } from 'requests/getUserSportFavs' import type { UserFavorites } from 'requests/getUserSportFavs'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
import { SportIcon } from 'components/SportIcon/SportIcon' import { SportIcon } from 'components/SportIcon/SportIcon'
@ -69,7 +71,7 @@ export const GroupBlock = ({ groupBlock }: Props) => {
<Name>{name}</Name> <Name>{name}</Name>
<CountryAndTeamInfo> <CountryAndTeamInfo>
<SportIcon sport={item.sport} size={10} /> <SportIcon sport={item.sport} size={10} />
<Flag src={`https://cf-aws.insports.tv/media/flags/${item.info.country?.id}.png`} /> <Flag src={`${URL_AWS}/media/flags/${item.info.country?.id}.png`} />
<EmptySpan>{countryOrTeam}</EmptySpan> <EmptySpan>{countryOrTeam}</EmptySpan>
</CountryAndTeamInfo> </CountryAndTeamInfo>
</EmptyDiv> </EmptyDiv>

@ -2,7 +2,11 @@ import { Fragment } from 'react'
import map from 'lodash/map' import map from 'lodash/map'
import { SportTypes, ProfileTypes } from 'config' import {
SportTypes,
ProfileTypes,
URL_AWS,
} from 'config'
import { isMobileDevice } from 'config/userAgent' import { isMobileDevice } from 'config/userAgent'
import { Gender } from 'requests' import { Gender } from 'requests'
@ -55,7 +59,7 @@ export const ItemsList = ({
<SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={item.sport} /> <SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={item.sport} />
{item.additionalInfo && ( {item.additionalInfo && (
<Fragment> <Fragment>
<Flag src={`https://cf-aws.insports.tv/media/flags/${item.additionalInfo.id}.png`} /> <Flag src={`${URL_AWS}/media/flags/${item.additionalInfo.id}.png`} />
<TeamOrCountry nameObj={item.additionalInfo} /> <TeamOrCountry nameObj={item.additionalInfo} />
</Fragment> </Fragment>
)} )}

@ -1,11 +1,12 @@
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
import { Wrapper } from 'features/PreferencesPopup/styled' import { Wrapper } from 'features/PreferencesPopup/styled'
import { ItemInfo } from 'components/ItemInfo/ItemInfo' import { ItemInfo } from 'components/ItemInfo/ItemInfo'
import type { FavouriteTeams } from 'requests/getFavouriteTeam' import type { FavouriteTeams } from 'requests/getFavouriteTeam'
import { SportTypes } from 'config'
import { useFavouriteTeam } from './hooks' import { useFavouriteTeam } from './hooks'
import { import {
@ -49,6 +50,7 @@ export const FavouriteTeamPopup = () => {
key={team.id} key={team.id}
id={team.id} id={team.id}
name={team.name_en} name={team.name_en}
sportId={SportTypes.FOOTBALL}
type={2} type={2}
onClick={() => changeActive(team)} onClick={() => changeActive(team)}
/> />
@ -66,6 +68,7 @@ export const FavouriteTeamPopup = () => {
key={team.id} key={team.id}
id={team.id} id={team.id}
name={team.name_en} name={team.name_en}
sportId={SportTypes.FOOTBALL}
type={2} type={2}
onClick={() => changeActive(team)} onClick={() => changeActive(team)}
/> />

@ -1,6 +1,7 @@
import styled, { css } from 'styled-components/macro' import styled, { css } from 'styled-components/macro'
import { isMobileDevice } from 'config/userAgent' import { isMobileDevice } from 'config/userAgent'
import { URL_AWS } from 'config'
import type { Tournament } from 'requests/getSportTournaments' import type { Tournament } from 'requests/getSportTournaments'
@ -51,7 +52,7 @@ export const TournamentInfo = ({
<StyledName nameObj={tournament} className='title' prefix={prefix} /> <StyledName nameObj={tournament} className='title' prefix={prefix} />
<ItemInfo> <ItemInfo>
{isIcon && <SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={tournament.sport} />} {isIcon && <SportIcon size={isMobileDevice ? 10 : '0.65rem'} sport={tournament.sport} />}
<Flag src={`https://cf-aws.insports.tv/media/flags/${tournament.country.id}.png`} /> <Flag src={`${URL_AWS}/media/flags/${tournament.country.id}.png`} />
<TeamOrCountry nameObj={tournament.country} /> <TeamOrCountry nameObj={tournament.country} />
</ItemInfo> </ItemInfo>
</Wrapper> </Wrapper>

@ -4,7 +4,11 @@ import { Link } from 'react-router-dom'
import type { ObjectWithName } from 'features/Name' import type { ObjectWithName } from 'features/Name'
import { PAGES, ProfileTypes } from 'config' import {
PAGES,
ProfileTypes,
URL_AWS,
} from 'config'
import { client, isLffClient } from 'config/clients' import { client, isLffClient } from 'config/clients'
import { ClientNames } from 'config/clients/types' import { ClientNames } from 'config/clients/types'
@ -75,7 +79,7 @@ export const ProfileCard = ({ profile }: ProfileType) => {
<Details> <Details>
<ProfileName>{name}</ProfileName> <ProfileName>{name}</ProfileName>
<InfoItems> <InfoItems>
<InfoFlag src={`https://cf-aws.insports.tv/media/flags/${profile.additionalInfo.id}.png`} /> <InfoFlag src={`${URL_AWS}/media/flags/${profile.additionalInfo.id}.png`} />
{tournamentId {tournamentId
? ( ? (
<StyledLink <StyledLink

@ -9,7 +9,6 @@ import { ProfileTypes, SportTypes } from 'config'
import { import {
getProfileFallbackLogo, getProfileFallbackLogo,
getProfileLogo, getProfileLogo,
readToken,
} from 'helpers' } from 'helpers'
import { Image } from 'features/Common' import { Image } from 'features/Common'
@ -26,18 +25,10 @@ type ProfileImageProps = {
onLoad?: () => void, onLoad?: () => void,
prefix?: string, prefix?: string,
profileType: ProfileTypes, profileType: ProfileTypes,
size?: number,
sportType: SportTypes, sportType: SportTypes,
title?: string, title?: string,
} }
type AwsMediaFlags = {
cover_url: 'string' | null,
landing_mobile_url: 'string' | null,
landing_url: 'string' | null,
logo_url: 'string' | null,
}
export const ProfileLogo = ({ export const ProfileLogo = ({
alt, alt,
altNameObj, altNameObj,
@ -48,7 +39,6 @@ export const ProfileLogo = ({
onLoad, onLoad,
prefix, prefix,
profileType, profileType,
size,
sportType, sportType,
title, title,
}: ProfileImageProps) => { }: ProfileImageProps) => {
@ -57,50 +47,15 @@ export const ProfileLogo = ({
const altName = useName(altNameObj || {}, prefix) const altName = useName(altNameObj || {}, prefix)
const titleText = nameAsTitle ? altName : title const titleText = nameAsTitle ? altName : title
const awsSrc = getProfileLogo({ const awsSrc = getProfileLogo({
awsInError: false,
id, id,
profileType, profileType,
size,
sportType,
})
const scoutSrc = getProfileLogo({
awsInError: true,
id,
profileType,
size,
sportType, sportType,
}) })
const fallbackSrc = getProfileFallbackLogo(profileType) const fallbackSrc = getProfileFallbackLogo(profileType)
useEffect(() => { useEffect(() => {
(async () => { setImageSource(logoUrl || awsSrc)
// если нет logoUrl, то нужно делать запрос в aws }, [awsSrc, logoUrl])
// если logoUrl === null, то это уже ответ с aws
if (logoUrl === null) {
setImageSource(scoutSrc)
return
}
if (logoUrl) {
setImageSource(logoUrl)
return
}
try {
const { logo_url }: AwsMediaFlags = await (await fetch(awsSrc, {
headers: { Authorization: `Bearer ${readToken()}` },
})).json()
if (logo_url) {
setImageSource(logo_url)
return
}
setImageSource(scoutSrc)
} catch (error) {
setImageSource(scoutSrc)
}
})()
}, [awsSrc, logoUrl, scoutSrc])
return ( return (
<Fragment> <Fragment>

@ -1,4 +1,4 @@
import { ProfileTypes } from 'config' import { ProfileTypes, URL_AWS } from 'config'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
import { Icon } from 'features/Icon' import { Icon } from 'features/Icon'
@ -93,7 +93,7 @@ export const CollapseTournament = ({
</SportWrapper> </SportWrapper>
<CountryWrapper> <CountryWrapper>
<CountryFlag <CountryFlag
src={`https://cf-aws.insports.tv/media/flags/${countryId}.png`} src={`${URL_AWS}/media/flags/${countryId}.png`}
/> />
{countryInfo && ( {countryInfo && (
<Tooltip> <Tooltip>

@ -1,6 +1,7 @@
import { Fragment, useState } from 'react' import { Fragment, useState } from 'react'
import { isLffClient } from 'config/clients' import { isLffClient } from 'config/clients'
import { URL_AWS } from 'config'
import { SportIcon } from 'components/SportIcon/SportIcon' import { SportIcon } from 'components/SportIcon/SportIcon'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
@ -54,7 +55,7 @@ export const TournamentMobile = ({
sport={sportType} sport={sportType}
/> />
<CountryFlag <CountryFlag
src={`https://cf-aws.insports.tv/media/flags/${countryId}.png`} src={`${URL_AWS}/media/flags/${countryId}.png`}
/> />
</Fragment> </Fragment>
)} )}

@ -6,7 +6,11 @@ import { Name } from 'features/Name'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
import { useUserFavoritesStore } from 'features/UserFavorites/store' import { useUserFavoritesStore } from 'features/UserFavorites/store'
import { ProfileTypes, SportTypes } from 'config' import {
ProfileTypes,
SportTypes,
URL_AWS,
} from 'config'
import { isLffClient } from 'config/clients' import { isLffClient } from 'config/clients'
import { isMobileDevice } from 'config/userAgent' import { isMobileDevice } from 'config/userAgent'
@ -72,7 +76,7 @@ export const TournamentSubtitle = ({
)} )}
</SportWrapper> </SportWrapper>
<CountryWrapper> <CountryWrapper>
<CountryFlag src={`https://cf-aws.insports.tv/media/flags/${countryId}.png`} /> <CountryFlag src={`${URL_AWS}/media/flags/${countryId}.png`} />
{countryInfo && ( {countryInfo && (
<Tooltip> <Tooltip>
<Name nameObj={countryInfo} /> <Name nameObj={countryInfo} />

@ -2,6 +2,8 @@ import { UserFavorite } from 'requests'
import { Name, useName } from 'features/Name' import { Name, useName } from 'features/Name'
import { URL_AWS } from 'config'
import { import {
TooltipBlockWrapper, TooltipBlockWrapper,
TooltipBlockItem, TooltipBlockItem,
@ -32,7 +34,7 @@ export const TooltipBlock = ({
</TooltipBlockItem> </TooltipBlockItem>
<TooltipBlockItemThin> <TooltipBlockItemThin>
{info?.team && <Name nameObj={info.team} />}{' '} {info?.team && <Name nameObj={info.team} />}{' '}
{info?.country && <Flag src={`https://cf-aws.insports.tv/media/flags/${info.country.id}.png`} />} {info?.country && <Flag src={`${URL_AWS}/media/flags/${info.country.id}.png`} />}
</TooltipBlockItemThin> </TooltipBlockItemThin>
</TooltipBlockWrapper> </TooltipBlockWrapper>
) )

@ -8,18 +8,18 @@ describe('getLogo helper', () => {
id: 1, id: 1,
profileType: ProfileTypes.PLAYERS, profileType: ProfileTypes.PLAYERS,
sportType: SportTypes.FOOTBALL, sportType: SportTypes.FOOTBALL,
})).toBe('https://api.test.insports.tv/v1/players/1/1/media') })).toBe('https://cf-aws.insports.tv/media/players/1/1/photo.png')
expect(getProfileLogo({ expect(getProfileLogo({
id: 1, id: 1,
profileType: ProfileTypes.TEAMS, profileType: ProfileTypes.TEAMS,
sportType: SportTypes.BASKETBALL, sportType: SportTypes.BASKETBALL,
})).toBe('https://api.test.insports.tv/v1/teams/3/1/media') })).toBe('https://cf-aws.insports.tv/media/teams/3/1/logo.jpg')
expect(getProfileLogo({ expect(getProfileLogo({
id: 1, id: 1,
profileType: ProfileTypes.TOURNAMENTS, profileType: ProfileTypes.TOURNAMENTS,
sportType: SportTypes.HOCKEY, sportType: SportTypes.HOCKEY,
})).toBe('https://api.test.insports.tv/v1/tournaments/2/1/media') })).toBe('https://cf-aws.insports.tv/media/tournaments/2/1/logo.jpg')
}) })
}) })

@ -1,37 +1,18 @@
import { import {
SportTypes,
ProfileTypes,
PROFILE_NAMES, PROFILE_NAMES,
API_ROOT, ProfileTypes,
SportTypes,
URL_AWS,
} from 'config' } 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 = { type GetLogoArgs = {
awsInError?: boolean,
id: number, id: number,
profileType: ProfileTypes, profileType: ProfileTypes,
size?: number,
sportType: SportTypes, sportType: SportTypes,
} }
export const getProfileLogo = ({ export const getProfileLogo = ({
awsInError,
id, id,
profileType, profileType,
size = 180,
sportType, sportType,
}: GetLogoArgs) => { }: GetLogoArgs) => `${URL_AWS}/media/${PROFILE_NAMES[profileType]}/${sportType}/${id}/${profileType === ProfileTypes.PLAYERS ? 'photo.png' : 'logo.jpg'}`
if (awsInError) {
return `${IMAGES_URLS[sportType]}/${PROFILE_NAMES[profileType]}/${size}/${id}.png`
}
return `${API_ROOT}/v1/${PROFILE_NAMES[profileType]}/${sportType}/${id}/media`
}

@ -8,6 +8,7 @@ import { SportIcon } from 'features/SportIcon'
import { ArrowLoader } from 'features/ArrowLoader' import { ArrowLoader } from 'features/ArrowLoader'
import { isMobileDevice } from 'config/userAgent' import { isMobileDevice } from 'config/userAgent'
import { URL_AWS } from 'config'
import { dateForIos } from 'helpers/dateForIos' import { dateForIos } from 'helpers/dateForIos'
@ -75,7 +76,7 @@ export const MatchesHighlights = () => {
<ScTournament> <ScTournament>
<SportIcon sport={sport} /> <SportIcon sport={sport} />
<ScCountryFlag <ScCountryFlag
src={`https://cf-aws.insports.tv/media/flags/${country_id}.png`} src={`${URL_AWS}/media/flags/${country_id}.png`}
/> />
<ScTournamentName>{tournament.name_eng}</ScTournamentName> <ScTournamentName>{tournament.name_eng}</ScTournamentName>
</ScTournament> </ScTournament>

@ -23,7 +23,7 @@ export function makeServer({ environment = 'test' } = {}) {
this.passthrough('https://insports.tv/***') this.passthrough('https://insports.tv/***')
this.passthrough('https://images.insports.tv/***') this.passthrough('https://images.insports.tv/***')
this.passthrough('https://auth.insports.tv/***') this.passthrough('https://auth.insports.tv/***')
this.passthrough('https://cf-aws.insports.tv/***') this.passthrough('${URL_AWS}/***')
this.get('https://api.insports.tv/v1/survey/teams/1/131/30', (schema: any) => schema.all('surveys').models[0].attrs) this.get('https://api.insports.tv/v1/survey/teams/1/131/30', (schema: any) => schema.all('surveys').models[0].attrs)
}, },
}) })

Loading…
Cancel
Save