|
|
|
@ -18,8 +18,10 @@ export const useTournaments = (matches: Array<Match>) => { |
|
|
|
return sport === sportName |
|
|
|
return sport === sportName |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const tournaments = matches.reduce((acc: Array<TournamentListProps> | [], match: Match) => { |
|
|
|
const tournamentSort: Array<number> = [] |
|
|
|
if (matches.length === 0) return [] |
|
|
|
|
|
|
|
|
|
|
|
const tournaments = matches.reduce((acc: TournamentListProps, match: Match) => { |
|
|
|
|
|
|
|
if (matches.length === 0) return {} |
|
|
|
if (!acc[match.tournament.id] && compareSport(match, selectedSport)) { |
|
|
|
if (!acc[match.tournament.id] && compareSport(match, selectedSport)) { |
|
|
|
const tournament = { |
|
|
|
const tournament = { |
|
|
|
...match.tournament, |
|
|
|
...match.tournament, |
|
|
|
@ -34,6 +36,7 @@ export const useTournaments = (matches: Array<Match>) => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
tournamentMatches: [match], |
|
|
|
tournamentMatches: [match], |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tournamentSort.push(match.tournament.id) |
|
|
|
} else if (compareSport(match, selectedSport)) { |
|
|
|
} else if (compareSport(match, selectedSport)) { |
|
|
|
acc[match.tournament.id] = { |
|
|
|
acc[match.tournament.id] = { |
|
|
|
...acc[match.tournament.id], |
|
|
|
...acc[match.tournament.id], |
|
|
|
@ -47,9 +50,10 @@ export const useTournaments = (matches: Array<Match>) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return acc |
|
|
|
return acc |
|
|
|
}, []) |
|
|
|
}, {}) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
|
|
|
|
tournamentSort, |
|
|
|
tournaments, |
|
|
|
tournaments, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|