fix(#664): add params to landing page

pull/232/head
andreidekterev 3 years ago
parent 27b91ac3a0
commit 795a8237f7
  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_description_1: 20084,
inactive_description_2: 20086,
inactive_period: 801,
inactive_title_1: 20087,
inactive_title_2: 20088,
}

@ -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<Landing | null>(null)
@ -29,7 +29,7 @@ export const useLandings = () => {
const [nonExistLogoSrc, setNonExistLogoSrc] = useState('')
const [tournamentProfile, setTournamentProfile] = useState<TournamentInfo>(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,

@ -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 = () => {
<Fragment>
<DateInfo>
{isInactiveLanding
? <T9n t='inactive_period' />
? season
: <T9n t='default_season' />}&nbsp;
{isInactiveLandingData?.season}
</DateInfo>
<TournamentTitle>
<T9n t='inactive_title_1' />&nbsp;
{isInactiveLandingData?.tournamentsTitle || defaultTournamentName}&nbsp;
{tournamentName || defaultTournamentName}&nbsp;
<T9n t='inactive_title_2' />
</TournamentTitle>
<TournamentDescription>
<T9n t='inactive_description_1' />&nbsp;
{isInactiveLandingData?.tournamentsTitle || defaultTournamentName}&nbsp;
{tournamentName || defaultTournamentName}&nbsp;
<T9n t='inactive_description_2' />
</TournamentDescription>
</Fragment>

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

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

Loading…
Cancel
Save