You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
861 B
49 lines
861 B
import map from 'lodash/map'
|
|
|
|
import format from 'date-fns/format'
|
|
|
|
import type { Match } from 'requests'
|
|
import { getSportLexic } from 'helpers'
|
|
|
|
const prepareMatch = ({
|
|
access,
|
|
date: matchDate,
|
|
has_video,
|
|
id,
|
|
live,
|
|
preview,
|
|
sport,
|
|
storage,
|
|
sub,
|
|
team1,
|
|
team2,
|
|
tournament,
|
|
}: Match) => {
|
|
const date = new Date(matchDate)
|
|
return {
|
|
accessibleBySubscription: sub,
|
|
accessibleInUsersCountry: access,
|
|
date,
|
|
formattedDate: format(date, 'dd.MM.yy'),
|
|
hasVideo: has_video,
|
|
id,
|
|
isClickable: (sub && access && (
|
|
has_video
|
|
|| storage
|
|
)),
|
|
live,
|
|
preview,
|
|
sportName: getSportLexic(sport),
|
|
sportType: sport,
|
|
storage,
|
|
team1,
|
|
team2,
|
|
time: format(date, 'HH:mm'),
|
|
tournament,
|
|
}
|
|
}
|
|
|
|
export const prepareMatches = (matches: Array<Match>) => map(
|
|
matches,
|
|
prepareMatch,
|
|
)
|
|
|