fix(#664): add params to landing page

andreidekterev 3 years ago
parent 1e0a2cfc2d
commit fa6cf88870
  1. 1
      src/config/lexics/landingLexics.tsx
  2. 27
      src/features/Landings/hooks.tsx
  3. 14
      src/features/Landings/index.tsx
  4. 7
      src/features/MatchPage/store/hooks/index.tsx
  5. 6
      src/requests/getMatchInfo.tsx

@ -3,7 +3,6 @@ export const landingLexics = {
inactive_button: 20083, inactive_button: 20083,
inactive_description_1: 20084, inactive_description_1: 20084,
inactive_description_2: 20086, inactive_description_2: 20086,
inactive_period: 801,
inactive_title_1: 20087, inactive_title_1: 20087,
inactive_title_2: 20088, inactive_title_2: 20088,
} }

@ -20,7 +20,7 @@ import { useLexicsStore } from 'features/LexicsStore'
import { useAuthStore } from 'features/AuthStore' import { useAuthStore } from 'features/AuthStore'
import { getLandingName, isPastLandingDate } from './helpers' import { getLandingName, isPastLandingDate } from './helpers'
import { getName, useName } from '../Name' import { useName } from '../Name'
export const useLandings = () => { export const useLandings = () => {
const [tournamentInfo, setTournamentInfo] = useState<Landing | null>(null) const [tournamentInfo, setTournamentInfo] = useState<Landing | null>(null)
@ -29,7 +29,7 @@ export const useLandings = () => {
const [nonExistLogoSrc, setNonExistLogoSrc] = useState('') const [nonExistLogoSrc, setNonExistLogoSrc] = useState('')
const [tournamentProfile, setTournamentProfile] = useState<TournamentInfo>(null) const [tournamentProfile, setTournamentProfile] = useState<TournamentInfo>(null)
const { addLexicsConfig, suffix } = useLexicsStore() const { addLexicsConfig } = useLexicsStore()
const { const {
landingUrlFrom, landingUrlFrom,
setIsFromLanding, setIsFromLanding,
@ -115,28 +115,6 @@ export const useLandings = () => {
return () => clearInterval(getSliderInterval) return () => clearInterval(getSliderInterval)
}, [imgCounter, sliderItemId]) }, [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 || {}) const defaultTournamentName = useName(tournamentProfile || {})
return { return {
@ -146,7 +124,6 @@ export const useLandings = () => {
description, description,
gallery, gallery,
isInactiveLanding, isInactiveLanding,
isInactiveLandingData: isInactiveLandingData(),
isNonExistLanding, isNonExistLanding,
logo: tournamentInfo?.media.logo, logo: tournamentInfo?.media.logo,
logoInsports: tournamentInfo?.logo_insports, logoInsports: tournamentInfo?.logo_insports,

@ -8,6 +8,8 @@ import { isMobileDevice } from 'config'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
import { checkUrlParams } from 'helpers/parseUrlParams/parseUrlParams'
import { useLandings } from './hooks' import { useLandings } from './hooks'
import { TeamLogoImg } from './TeamLogoImg' import { TeamLogoImg } from './TeamLogoImg'
@ -39,6 +41,9 @@ import {
} from './styled' } from './styled'
const Landings = () => { const Landings = () => {
const season = checkUrlParams('season')
const tournamentName = checkUrlParams('tournament')
const { const {
buttonColor, buttonColor,
buttonLexic, buttonLexic,
@ -46,7 +51,6 @@ const Landings = () => {
description, description,
gallery, gallery,
isInactiveLanding, isInactiveLanding,
isInactiveLandingData,
isNonExistLanding, isNonExistLanding,
logo, logo,
logoInsports, logoInsports,
@ -117,18 +121,18 @@ const Landings = () => {
<Fragment> <Fragment>
<DateInfo> <DateInfo>
{isInactiveLanding {isInactiveLanding
? <T9n t='inactive_period' /> ? season
: <T9n t='default_season' />}&nbsp; : <T9n t='default_season' />}&nbsp;
{isInactiveLandingData?.season}
</DateInfo> </DateInfo>
<TournamentTitle> <TournamentTitle>
<T9n t='inactive_title_1' />&nbsp; <T9n t='inactive_title_1' />&nbsp;
{isInactiveLandingData?.tournamentsTitle || defaultTournamentName}&nbsp; {tournamentName || defaultTournamentName}&nbsp;
<T9n t='inactive_title_2' /> <T9n t='inactive_title_2' />
</TournamentTitle> </TournamentTitle>
<TournamentDescription> <TournamentDescription>
<T9n t='inactive_description_1' />&nbsp; <T9n t='inactive_description_1' />&nbsp;
{isInactiveLandingData?.tournamentsTitle || defaultTournamentName}&nbsp; {tournamentName || defaultTournamentName}&nbsp;
<T9n t='inactive_description_2' /> <T9n t='inactive_description_2' />
</TournamentDescription> </TournamentDescription>
</Fragment> </Fragment>

@ -36,6 +36,7 @@ import { useTabEvents } from './useTabEvents'
import { useTeamsStats } from './useTeamsStats' import { useTeamsStats } from './useTeamsStats'
import { useStatsTab } from './useStatsTab' import { useStatsTab } from './useStatsTab'
import { usePlayersStats } from './usePlayersStats' import { usePlayersStats } from './usePlayersStats'
import { useLexicsStore } from '../../../LexicsStore'
type PlayingData = { type PlayingData = {
player: { player: {
@ -82,6 +83,7 @@ export const useMatchPage = () => {
paramName: '', paramName: '',
playerOrTeamName: '', playerOrTeamName: '',
}) })
const { suffix } = useLexicsStore()
const { profileId: matchId, sportType } = usePageParams() const { profileId: matchId, sportType } = usePageParams()
@ -175,7 +177,10 @@ export const useMatchPage = () => {
sportType, sportType,
tournamentId: data?.tournament.id, 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 // eslint-disable-next-line react-hooks/exhaustive-deps

@ -28,6 +28,11 @@ export type MatchTournament = {
sportType: number, sportType: number,
} }
export type MatchSeason = {
id: number,
name: string,
}
export type VideoBound = { export type VideoBound = {
e: string, e: string,
h: string, h: string,
@ -55,6 +60,7 @@ export type MatchInfo = {
has_video: boolean, has_video: boolean,
live: boolean, live: boolean,
playbackUrl?: string, playbackUrl?: string,
season: MatchSeason,
sport: SportInfo, sport: SportInfo,
storage: boolean, storage: boolean,
sub: boolean, sub: boolean,

Loading…
Cancel
Save