From d48935c011416ae869516ffed82afa4b96be6fb0 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Wed, 11 May 2022 15:49:49 +0700 Subject: [PATCH] fix(#2425): fix show teams and tournaments pages --- src/features/MatchesGrid/index.tsx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/features/MatchesGrid/index.tsx b/src/features/MatchesGrid/index.tsx index 0f1b16b6..415e4384 100644 --- a/src/features/MatchesGrid/index.tsx +++ b/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 ( {isHomePage && isShowTournament ? ( - + ) : ( - filteredMatches.filter((match) => ((selectedLeague.indexOf(match.tournament.id) >= 0 - || selectedLeague[0] === 'all_competitions'))).map((match) => ) + filteredMatches().map((match) => ) )} )