|
|
|
|
@ -9,6 +9,16 @@ import { useRequest, useToggle } from 'hooks' |
|
|
|
|
|
|
|
|
|
import { useHeaderFiltersStore } from 'features/HeaderFilters' |
|
|
|
|
|
|
|
|
|
const findTournament = (tournaments: Tournaments, id: number) => { |
|
|
|
|
const tournament = find(tournaments, { id }) |
|
|
|
|
if (!tournament) return null |
|
|
|
|
return { |
|
|
|
|
...tournament, |
|
|
|
|
name_eng: tournament.short_name_eng || tournament.name_eng, |
|
|
|
|
name_rus: tournament.short_name_rus || tournament.name_rus, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const useTournamentFilter = () => { |
|
|
|
|
const [tournaments, setTournaments] = useState<Tournaments>([]) |
|
|
|
|
|
|
|
|
|
@ -44,10 +54,9 @@ export const useTournamentFilter = () => { |
|
|
|
|
setPage(page + 1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const selectedTournament = find( |
|
|
|
|
tournaments, |
|
|
|
|
(tournament) => tournament.id === selectedTournamentId, |
|
|
|
|
) |
|
|
|
|
const selectedTournament = selectedTournamentId |
|
|
|
|
? findTournament(tournaments, selectedTournamentId) |
|
|
|
|
: null |
|
|
|
|
|
|
|
|
|
const onTournamentSelect = (tournamentId: number) => { |
|
|
|
|
setSelectedTournamentId(tournamentId) |
|
|
|
|
|