From 795a8237f70c252af10ce2fed05590374620f7f1 Mon Sep 17 00:00:00 2001 From: andreidekterev Date: Wed, 7 Jun 2023 22:17:51 +0700 Subject: [PATCH] fix(#664): add params to landing page --- src/config/lexics/landingLexics.tsx | 1 - src/features/Landings/hooks.tsx | 27 ++------------------ src/features/Landings/index.tsx | 14 ++++++---- src/features/MatchPage/store/hooks/index.tsx | 7 ++++- src/requests/getMatchInfo.tsx | 6 +++++ 5 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/config/lexics/landingLexics.tsx b/src/config/lexics/landingLexics.tsx index fb81f158..b6184100 100644 --- a/src/config/lexics/landingLexics.tsx +++ b/src/config/lexics/landingLexics.tsx @@ -3,7 +3,6 @@ export const landingLexics = { inactive_button: 20083, inactive_description_1: 20084, inactive_description_2: 20086, - inactive_period: 801, inactive_title_1: 20087, inactive_title_2: 20088, } diff --git a/src/features/Landings/hooks.tsx b/src/features/Landings/hooks.tsx index 3683c5a6..bdad0f12 100644 --- a/src/features/Landings/hooks.tsx +++ b/src/features/Landings/hooks.tsx @@ -20,7 +20,7 @@ import { useLexicsStore } from 'features/LexicsStore' import { useAuthStore } from 'features/AuthStore' import { getLandingName, isPastLandingDate } from './helpers' -import { getName, useName } from '../Name' +import { useName } from '../Name' export const useLandings = () => { const [tournamentInfo, setTournamentInfo] = useState(null) @@ -29,7 +29,7 @@ export const useLandings = () => { const [nonExistLogoSrc, setNonExistLogoSrc] = useState('') const [tournamentProfile, setTournamentProfile] = useState(null) - const { addLexicsConfig, suffix } = useLexicsStore() + const { addLexicsConfig } = useLexicsStore() const { landingUrlFrom, setIsFromLanding, @@ -115,28 +115,6 @@ export const useLandings = () => { return () => clearInterval(getSliderInterval) }, [imgCounter, sliderItemId]) - const isInactiveLandingData = () => { - if (!tournamentInfo?.tournaments || !isInactiveLanding) return null - - const { - season, - tournament_eng, - tournament_rus, - } = tournamentInfo.tournaments[0] - - const currentTournamentsTitle = { - name_eng: tournament_eng, - name_rus: tournament_rus, - } - - const tournamentsTitle = getName({ nameObj: currentTournamentsTitle, suffix }) - - return { - season, - tournamentsTitle, - } - } - const defaultTournamentName = useName(tournamentProfile || {}) return { @@ -146,7 +124,6 @@ export const useLandings = () => { description, gallery, isInactiveLanding, - isInactiveLandingData: isInactiveLandingData(), isNonExistLanding, logo: tournamentInfo?.media.logo, logoInsports: tournamentInfo?.logo_insports, diff --git a/src/features/Landings/index.tsx b/src/features/Landings/index.tsx index 03150bde..c25cf191 100644 --- a/src/features/Landings/index.tsx +++ b/src/features/Landings/index.tsx @@ -8,6 +8,8 @@ import { isMobileDevice } from 'config' import { T9n } from 'features/T9n' +import { checkUrlParams } from 'helpers/parseUrlParams/parseUrlParams' + import { useLandings } from './hooks' import { TeamLogoImg } from './TeamLogoImg' @@ -39,6 +41,9 @@ import { } from './styled' const Landings = () => { + const season = checkUrlParams('season') + const tournamentName = checkUrlParams('tournament') + const { buttonColor, buttonLexic, @@ -46,7 +51,6 @@ const Landings = () => { description, gallery, isInactiveLanding, - isInactiveLandingData, isNonExistLanding, logo, logoInsports, @@ -117,18 +121,18 @@ const Landings = () => { {isInactiveLanding - ? + ? season : }  - {isInactiveLandingData?.season} +   - {isInactiveLandingData?.tournamentsTitle || defaultTournamentName}  + {tournamentName || defaultTournamentName}    - {isInactiveLandingData?.tournamentsTitle || defaultTournamentName}  + {tournamentName || defaultTournamentName}  diff --git a/src/features/MatchPage/store/hooks/index.tsx b/src/features/MatchPage/store/hooks/index.tsx index 30bf93db..e4624170 100644 --- a/src/features/MatchPage/store/hooks/index.tsx +++ b/src/features/MatchPage/store/hooks/index.tsx @@ -36,6 +36,7 @@ import { useTabEvents } from './useTabEvents' import { useTeamsStats } from './useTeamsStats' import { useStatsTab } from './useStatsTab' import { usePlayersStats } from './usePlayersStats' +import { useLexicsStore } from '../../../LexicsStore' type PlayingData = { player: { @@ -82,6 +83,7 @@ export const useMatchPage = () => { paramName: '', playerOrTeamName: '', }) + const { suffix } = useLexicsStore() const { profileId: matchId, sportType } = usePageParams() @@ -175,7 +177,10 @@ export const useMatchPage = () => { sportType, tournamentId: data?.tournament.id, })) - redirectToUrl(`${PAGES.landing}/default`) + redirectToUrl(` + ${PAGES.landing}/default + ?season=${data?.season.name} + &tournament=${data?.tournament[`name_${suffix}`]}`) }) }) // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/requests/getMatchInfo.tsx b/src/requests/getMatchInfo.tsx index fc0da889..2e49db4b 100644 --- a/src/requests/getMatchInfo.tsx +++ b/src/requests/getMatchInfo.tsx @@ -28,6 +28,11 @@ export type MatchTournament = { sportType: number, } +export type MatchSeason = { + id: number, + name: string, +} + export type VideoBound = { e: string, h: string, @@ -55,6 +60,7 @@ export type MatchInfo = { has_video: boolean, live: boolean, playbackUrl?: string, + season: MatchSeason, sport: SportInfo, storage: boolean, sub: boolean,