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) => map( matches, prepareMatch, )