|
|
|
|
@ -23,21 +23,28 @@ export const MatchesGrid = memo(({ matches }: MatchesGridProps) => { |
|
|
|
|
selectedLeague, |
|
|
|
|
} = useHeaderFiltersStore() |
|
|
|
|
|
|
|
|
|
const filteredMatches = isHomePage && selectedFilters.length |
|
|
|
|
? matches.filter((match) => ( |
|
|
|
|
((match.live |
|
|
|
|
&& selectedFilters.indexOf('live') >= 0) |
|
|
|
|
|| (selectedFilters.indexOf('upcoming') >= 0 && match.date > new Date()) |
|
|
|
|
|| (selectedFilters.indexOf('completed') >= 0 && match.is_finished)))) |
|
|
|
|
: matches |
|
|
|
|
const filteredMatches = () => { |
|
|
|
|
if (isHomePage && selectedFilters.length && isShowTournament) { |
|
|
|
|
return matches.filter( |
|
|
|
|
(match) => (match.live && selectedFilters.indexOf('live') >= 0) |
|
|
|
|
|| (selectedFilters.indexOf('upcoming') >= 0 |
|
|
|
|
&& match.date > new Date()) |
|
|
|
|
|| (selectedFilters.indexOf('completed') >= 0 && match.is_finished), |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
if (isHomePage && selectedLeague.length && !isShowTournament) { |
|
|
|
|
return matches.filter((match) => ((selectedLeague.indexOf(match.tournament.id) >= 0 |
|
|
|
|
|| selectedLeague[0] === 'all_competitions'))) |
|
|
|
|
} |
|
|
|
|
return matches |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Wrapper> |
|
|
|
|
{isHomePage && isShowTournament ? ( |
|
|
|
|
<TournamentList matches={filteredMatches} /> |
|
|
|
|
<TournamentList matches={filteredMatches()} /> |
|
|
|
|
) : ( |
|
|
|
|
filteredMatches.filter((match) => ((selectedLeague.indexOf(match.tournament.id) >= 0 |
|
|
|
|
|| selectedLeague[0] === 'all_competitions'))).map((match) => <MatchCard key={match.id} match={match} />) |
|
|
|
|
filteredMatches().map((match) => <MatchCard key={match.id} match={match} />) |
|
|
|
|
)} |
|
|
|
|
</Wrapper> |
|
|
|
|
) |
|
|
|
|
|