|
|
|
|
@ -1,32 +1,45 @@ |
|
|
|
|
import { format } from 'date-fns' |
|
|
|
|
|
|
|
|
|
import includes from 'lodash/includes' |
|
|
|
|
|
|
|
|
|
import type { MatchInfo } from 'requests/getMatchInfo' |
|
|
|
|
|
|
|
|
|
import { Name } from 'features/Name' |
|
|
|
|
import { SportIcon } from 'components/SportIcon/SportIcon' |
|
|
|
|
import { T9n } from 'features/T9n' |
|
|
|
|
import { useAuthStore } from 'features/AuthStore' |
|
|
|
|
import { useMatchSwitchesStore } from 'features/MatchSwitches' |
|
|
|
|
|
|
|
|
|
import { parseDate } from 'helpers/parseDate' |
|
|
|
|
|
|
|
|
|
import { ProfileTypes } from 'config' |
|
|
|
|
|
|
|
|
|
import { usePageParams } from 'hooks/usePageParams' |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
CountryFlag, |
|
|
|
|
Description, |
|
|
|
|
DescriptionInnerBlock, |
|
|
|
|
MatchDate, |
|
|
|
|
StyledDash, |
|
|
|
|
StyledLink, |
|
|
|
|
Score, |
|
|
|
|
Title, |
|
|
|
|
Tournament, |
|
|
|
|
Views, |
|
|
|
|
Time, |
|
|
|
|
} from './styled' |
|
|
|
|
|
|
|
|
|
type Props = { |
|
|
|
|
profile: MatchInfo, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const MatchDescription = ({ profile }: Props) => { |
|
|
|
|
export const MatchDescription = ({ |
|
|
|
|
profile, |
|
|
|
|
}: Props) => { |
|
|
|
|
const { sportType } = usePageParams() |
|
|
|
|
const { user } = useAuthStore() |
|
|
|
|
const { isScoreHidden } = useMatchSwitchesStore() |
|
|
|
|
|
|
|
|
|
if (!profile) return <Description /> |
|
|
|
|
|
|
|
|
|
@ -39,46 +52,54 @@ export const MatchDescription = ({ profile }: Props) => { |
|
|
|
|
tournament, |
|
|
|
|
} = profile |
|
|
|
|
|
|
|
|
|
const localDate = format(parseDate(date), live ? 'HH:mm' : 'd.MM.Y') |
|
|
|
|
const isChangedTimeFormat = includes(['US', 'CA'], user?.profile.country_code) |
|
|
|
|
const localDate = format(parseDate(date), |
|
|
|
|
live ? 'HH:mm' : 'MMMM d, y') |
|
|
|
|
const changedTimeFormat = format(parseDate(date), |
|
|
|
|
isChangedTimeFormat ? 'hh:mm aaa' : 'hh:mm') |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Description> |
|
|
|
|
<Title> |
|
|
|
|
<StyledLink |
|
|
|
|
id={team1.id} |
|
|
|
|
profileType={ProfileTypes.TEAMS} |
|
|
|
|
sportType={sportType} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={team1} /> |
|
|
|
|
</StyledLink> |
|
|
|
|
— |
|
|
|
|
<StyledLink |
|
|
|
|
id={team2.id} |
|
|
|
|
profileType={ProfileTypes.TEAMS} |
|
|
|
|
sportType={sportType} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={team2} /> |
|
|
|
|
</StyledLink> |
|
|
|
|
{live ? '\u00a0|\u00a0LIVE STREAM' : ''} |
|
|
|
|
</Title> |
|
|
|
|
<Tournament> |
|
|
|
|
<SportIcon sport={sportType} /> |
|
|
|
|
<CountryFlag |
|
|
|
|
src={`https://instatscout.com/images/flags/48/${country_id}.png`} |
|
|
|
|
/> |
|
|
|
|
<StyledLink |
|
|
|
|
id={tournament.id} |
|
|
|
|
profileType={ProfileTypes.TOURNAMENTS} |
|
|
|
|
sportType={sportType} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={tournament} /> |
|
|
|
|
</StyledLink> |
|
|
|
|
</Tournament> |
|
|
|
|
<DescriptionInnerBlock> |
|
|
|
|
<Title> |
|
|
|
|
<StyledLink |
|
|
|
|
id={team1.id} |
|
|
|
|
profileType={ProfileTypes.TEAMS} |
|
|
|
|
sportType={sportType} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={team1} /> |
|
|
|
|
</StyledLink> |
|
|
|
|
{!isScoreHidden && <Score>{team1.score}</Score>} |
|
|
|
|
<StyledDash isScoreHidden={isScoreHidden}>-</StyledDash> |
|
|
|
|
{!isScoreHidden && <Score>{team2.score}</Score>} |
|
|
|
|
<StyledLink |
|
|
|
|
id={team2.id} |
|
|
|
|
profileType={ProfileTypes.TEAMS} |
|
|
|
|
sportType={sportType} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={team2} /> |
|
|
|
|
</StyledLink> |
|
|
|
|
{live ? '\u00a0|\u00a0LIVE STREAM' : ''} |
|
|
|
|
</Title> |
|
|
|
|
<Tournament> |
|
|
|
|
<SportIcon sport={sportType} /> |
|
|
|
|
<CountryFlag |
|
|
|
|
src={`https://instatscout.com/images/flags/48/${country_id}.png`} |
|
|
|
|
/> |
|
|
|
|
<StyledLink |
|
|
|
|
id={tournament.id} |
|
|
|
|
profileType={ProfileTypes.TOURNAMENTS} |
|
|
|
|
sportType={sportType} |
|
|
|
|
> |
|
|
|
|
<Name nameObj={tournament} /> |
|
|
|
|
</StyledLink> |
|
|
|
|
</Tournament> |
|
|
|
|
</DescriptionInnerBlock> |
|
|
|
|
<Views> |
|
|
|
|
{ |
|
|
|
|
live |
|
|
|
|
? <T9n t='started_streaming_at' /> |
|
|
|
|
: <T9n t='streamed_live_on' /> |
|
|
|
|
: <Time>{changedTimeFormat}</Time> |
|
|
|
|
} |
|
|
|
|
<MatchDate>{localDate}</MatchDate> |
|
|
|
|
</Views> |
|
|
|
|
|