|
|
|
|
@ -1,14 +1,9 @@ |
|
|
|
|
import React, { |
|
|
|
|
useState, |
|
|
|
|
useEffect, |
|
|
|
|
useCallback, |
|
|
|
|
} from 'react' |
|
|
|
|
import React from 'react' |
|
|
|
|
|
|
|
|
|
import styled from 'styled-components/macro' |
|
|
|
|
import differenceInMilliseconds from 'date-fns/differenceInMilliseconds' |
|
|
|
|
|
|
|
|
|
import type { Match } from 'features/Matches' |
|
|
|
|
import { getSportColor, msToMinutesAndSeconds } from 'helpers' |
|
|
|
|
import { getSportColor } from 'helpers' |
|
|
|
|
import { SportName } from 'features/Common' |
|
|
|
|
import { T9n } from 'features/T9n' |
|
|
|
|
|
|
|
|
|
@ -27,8 +22,6 @@ import { |
|
|
|
|
} from '../styled' |
|
|
|
|
import { CardLiveHover } from '../CardLiveHover' |
|
|
|
|
|
|
|
|
|
const UPDATE_INTERVAL = 1000 |
|
|
|
|
|
|
|
|
|
const MatchStatus = styled(CommonMatchStatus)` |
|
|
|
|
color: #fff; |
|
|
|
|
background-color: #cc0000; |
|
|
|
|
@ -60,21 +53,6 @@ export const CardLive = ({ |
|
|
|
|
showScore, |
|
|
|
|
} = useCard() |
|
|
|
|
|
|
|
|
|
const getMs = useCallback(() => differenceInMilliseconds( |
|
|
|
|
new Date(), |
|
|
|
|
new Date(date), |
|
|
|
|
), [date]) |
|
|
|
|
|
|
|
|
|
const [matchDuration, setMatchDuration] = useState(msToMinutesAndSeconds(getMs())) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
const timer = setInterval(() => { |
|
|
|
|
setMatchDuration(msToMinutesAndSeconds(getMs())) |
|
|
|
|
}, UPDATE_INTERVAL) |
|
|
|
|
|
|
|
|
|
return () => clearInterval(timer) |
|
|
|
|
}, [getMs]) |
|
|
|
|
|
|
|
|
|
if (isOpen) return <CardLiveHover onClose={close} /> |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
@ -82,7 +60,7 @@ export const CardLive = ({ |
|
|
|
|
onClick={open} |
|
|
|
|
onKeyPress={onKeyPress} |
|
|
|
|
> |
|
|
|
|
<MatchStatus><T9n t='live' /> {matchDuration}</MatchStatus> |
|
|
|
|
<MatchStatus><T9n t='live' /></MatchStatus> |
|
|
|
|
<PreviewWrapper> |
|
|
|
|
<Preview |
|
|
|
|
alt={tournamentName} |
|
|
|
|
|