import map from 'lodash/map'

import type { MatchesBySection, Matches } from 'requests'
import { SportTypes } from 'config'

const addSportTypeToMatches = (matches: Matches, sport: SportTypes) => (
  map(matches, (match) => ({ ...match, sport }))
)

export const addSportType = (matches: MatchesBySection, sport: SportTypes) => ({
  ...matches,
  broadcast: addSportTypeToMatches(matches.broadcast, sport),
  features: addSportTypeToMatches(matches.features, sport),
  highlights: addSportTypeToMatches(matches.highlights, sport),
})
