fix(#2425): fix show teams and tournaments pages

keep-around/b94d43885700f194c77b2df6808a62140a37e5f2
Andrei Dekterev 4 years ago
parent cc91d24df8
commit d48935c011
  1. 27
      src/features/MatchesGrid/index.tsx

@ -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>
)

Loading…
Cancel
Save