diff --git a/src/features/MatchCard/styled.tsx b/src/features/MatchCard/styled.tsx index 4c94755e..ba438635 100644 --- a/src/features/MatchCard/styled.tsx +++ b/src/features/MatchCard/styled.tsx @@ -188,7 +188,7 @@ export const Info = styled.div` flex-direction: column; padding: ${({ isMatchPage }) => (isMatchPage ? '0 5px 5px 0' : '0.85rem 0.472rem 0 0.519rem')}; color: #fff; - z-index: 1; + z-index: 2; ${isMobileDevice ? css` diff --git a/src/features/MatchesGrid/index.tsx b/src/features/MatchesGrid/index.tsx index 90270aa2..d2b93089 100644 --- a/src/features/MatchesGrid/index.tsx +++ b/src/features/MatchesGrid/index.tsx @@ -44,7 +44,7 @@ export const MatchesGrid = memo(({ matches }: MatchesGridProps) => { ) } if (isHomePage && selectedLeague.length && !isShowTournament) { - return matches.filter((match) => ((selectedLeague.indexOf(match.tournament.id) >= 0 + return matches.filter((match) => ((selectedLeague.indexOf(`${match.sportType}_${match.tournament.id}`) >= 0 || selectedLeague[0] === 'all_competitions'))) } @@ -73,6 +73,7 @@ export const MatchesGrid = memo(({ matches }: MatchesGridProps) => { updateSportIds(matches) // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedDate, matches]) + return ( {isHomePage && isShowTournament ? ( diff --git a/src/features/TournamentList/components/CollapseTournament/index.tsx b/src/features/TournamentList/components/CollapseTournament/index.tsx index 5992b826..31bc9dfe 100644 --- a/src/features/TournamentList/components/CollapseTournament/index.tsx +++ b/src/features/TournamentList/components/CollapseTournament/index.tsx @@ -46,7 +46,7 @@ export const CollapseTournament = ({ const handleClick = () => { setIsShowTournament(false) - setSelectedLeague([tournament.id]) + setSelectedLeague([`${tournament.sportType}_${tournament.id}`]) setSelectTournament(tournament) } diff --git a/src/features/TournamentList/hooks.tsx b/src/features/TournamentList/hooks.tsx index 7d13b3a7..ffe5c543 100644 --- a/src/features/TournamentList/hooks.tsx +++ b/src/features/TournamentList/hooks.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react' import orderBy from 'lodash/orderBy' -import { ProfileTypes } from 'config' +import { ProfileTypes, SportTypes } from 'config' import { TournamentListProps } from 'features/TournamentList' import type { Match } from 'features/Matches' import { useHeaderFiltersStore } from 'features/HeaderFilters' @@ -13,6 +13,7 @@ interface TournamentsSortProps { isFavorite: boolean, isLive: boolean, isSuperTournament: boolean, + sportType: SportTypes, } export const useTournaments = (matches: Array) => { @@ -23,7 +24,7 @@ export const useTournaments = (matches: Array) => { } = useHeaderFiltersStore() const { isInFavorites } = useUserFavoritesStore() - const compareLeague = (id: number) => { + const compareLeague = (id: number| string) => { if (selectedLeague[0] === 'all_competitions') { return true } @@ -36,14 +37,16 @@ export const useTournaments = (matches: Array) => { const tournaments = matches.reduce((acc: TournamentListProps, match: Match) => { if (matches.length === 0) return {} + const uniqTournamentId = `${match.sportType}_${match.tournament.id}` + const tournamentInFavorites = isInFavorites( ProfileTypes.TOURNAMENTS, // в избранном могут быть только обычные турниры match.tournament.is_super_tournament ? match.group.id : match.tournament.id, ) - if (!acc[match.tournament.id] && compareSport(match, selectedSport) - && compareLeague(match.tournament.id)) { + if (!acc[`${match.sportType}_${match.tournament.id}`] && compareSport(match, selectedSport) + && compareLeague(uniqTournamentId)) { const tournament = { ...match.tournament, countryId: match.countryId, @@ -52,7 +55,7 @@ export const useTournaments = (matches: Array) => { matches: [match], sportType: match.sportType, } - acc[match.tournament.id] = { + acc[uniqTournamentId] = { tournament: { ...tournament, }, @@ -63,17 +66,18 @@ export const useTournaments = (matches: Array) => { isFavorite: tournamentInFavorites, isLive: match.live, isSuperTournament: Boolean(match.tournament.is_super_tournament), + sportType: match.sportType, }) - } else if (compareSport(match, selectedSport) && compareLeague(match.tournament.id)) { - acc[match.tournament.id] = { - ...acc[match.tournament.id], + } else if (compareSport(match, selectedSport) && compareLeague(uniqTournamentId)) { + acc[uniqTournamentId] = { + ...acc[uniqTournamentId], tournament: { - ...acc[match.tournament.id].tournament, - live: acc[match.tournament.id]?.tournament.live - ? acc[match.tournament.id]?.tournament.live + ...acc[uniqTournamentId].tournament, + live: acc[uniqTournamentId]?.tournament.live + ? acc[uniqTournamentId]?.tournament.live : match.live, }, - tournamentMatches: [...acc[match.tournament.id].tournamentMatches, match], + tournamentMatches: [...acc[uniqTournamentId].tournamentMatches, match], } } return acc diff --git a/src/features/TournamentList/index.tsx b/src/features/TournamentList/index.tsx index 96215326..7407d515 100644 --- a/src/features/TournamentList/index.tsx +++ b/src/features/TournamentList/index.tsx @@ -27,7 +27,7 @@ export type TournamentProps = { } export type TournamentListProps = { - [key: number]: TournamentProps, + [key: string]: TournamentProps, } export const TournamentList = ({ matches }: TournamentTypeProps) => { @@ -38,11 +38,11 @@ export const TournamentList = ({ matches }: TournamentTypeProps) => { case isMobileDevice && isHomePage: return ( <> - {tournamentSort?.map(({ id }) => ( + {tournamentSort?.map(({ id, sportType }) => ( ))} @@ -50,11 +50,11 @@ export const TournamentList = ({ matches }: TournamentTypeProps) => { case isHomePage && matches.length >= 12: return ( <> - {tournamentSort?.map(({ id }) => ( + {tournamentSort?.map(({ id, sportType }) => ( ))}