import reduce from 'lodash/reduce'
import { MatchInfo, TeamStatItem } from 'requests'
import { TeamsStats } from 'features/MatchPage/store/hooks/useTeamsStats'

export type StatsLexicType = {
  matchProfile: MatchInfo,
  stats: TeamsStats,
}
export const getStatsLexics = ({ matchProfile, stats }: StatsLexicType) => (
  matchProfile
    ? reduce<TeamStatItem, Array<number>>(
      stats[matchProfile.team1.id],
      (acc, curr) => {
        !acc.includes(curr.lexic) && acc.push(curr.lexic)
        !acc.includes(curr.param1.lexic) && acc.push(curr.param1.lexic)
        curr.param2 && !acc.includes(curr.param2.lexic) && acc.push(curr.param2.lexic)

        return acc
      },
      [],
    )
    : [])
