|
|
|
@ -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 { useName } from '../Name' |
|
|
|
import { getName, 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 } = useLexicsStore() |
|
|
|
const { addLexicsConfig, suffix } = useLexicsStore() |
|
|
|
const { |
|
|
|
const { |
|
|
|
landingUrlFrom, |
|
|
|
landingUrlFrom, |
|
|
|
setIsFromLanding, |
|
|
|
setIsFromLanding, |
|
|
|
@ -67,15 +67,15 @@ export const useLandings = () => { |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
(async () => { |
|
|
|
(async () => { |
|
|
|
const landingData = sessionStorage.getItem('landingData') |
|
|
|
const landingData = sessionStorage.getItem('landingData') |
|
|
|
const parseLandingDate = landingData && JSON.parse(landingData) |
|
|
|
const parseLandingData = landingData && JSON.parse(landingData) |
|
|
|
|
|
|
|
|
|
|
|
if (parseLandingDate && parseLandingDate.defaultLanding) { |
|
|
|
if (parseLandingData && parseLandingData.defaultLanding) { |
|
|
|
setIsNonExistLanding(true) |
|
|
|
getTournamentInfo(parseLandingData.sportType, parseLandingData.tournamentId) |
|
|
|
getTournamentInfo(parseLandingDate.sportType, parseLandingDate.tournamentId) |
|
|
|
|
|
|
|
.then(setTournamentProfile) |
|
|
|
.then(setTournamentProfile) |
|
|
|
|
|
|
|
setIsNonExistLanding(true) |
|
|
|
return getLandingLogo({ |
|
|
|
return getLandingLogo({ |
|
|
|
sport_id: parseLandingDate.sportType, |
|
|
|
sport_id: parseLandingData.sportType, |
|
|
|
tournament_id: parseLandingDate.tournamentId, |
|
|
|
tournament_id: parseLandingData.tournamentId, |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(({ logo_url }) => setNonExistLogoSrc(logo_url || '/images/tournament-fallback.png')) |
|
|
|
.then(({ logo_url }) => setNonExistLogoSrc(logo_url || '/images/tournament-fallback.png')) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -83,15 +83,17 @@ export const useLandings = () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const data = landingUrlFrom |
|
|
|
const data = landingUrlFrom |
|
|
|
? await getLanding({ |
|
|
|
? await getLanding({ |
|
|
|
landingName: parseLandingDate.landing_id || parseLandingDate.url_landing, |
|
|
|
landingName: parseLandingData.landing_id || parseLandingData.url_landing, |
|
|
|
seasonId: parseLandingDate.season_id, |
|
|
|
seasonId: parseLandingData.season_id, |
|
|
|
sportId: parseLandingDate.sport_id, |
|
|
|
sportId: parseLandingData.sport_id, |
|
|
|
tournamentId: parseLandingDate.tournament_id, |
|
|
|
tournamentId: parseLandingData.tournament_id, |
|
|
|
}) |
|
|
|
}) |
|
|
|
: await getLanding({ landingName: getLandingName() }) |
|
|
|
: await getLanding({ landingName: getLandingName() }) |
|
|
|
|
|
|
|
|
|
|
|
if (user) return redirectToUrl(data.url_button || '') |
|
|
|
if (user) return redirectToUrl(data.url_button || '') |
|
|
|
|
|
|
|
|
|
|
|
if (isPastLandingDate(data.date_to)) setIsInactiveLanding(true) |
|
|
|
if (isPastLandingDate(data.date_to)) setIsInactiveLanding(true) |
|
|
|
|
|
|
|
|
|
|
|
return setTournamentInfo(data) |
|
|
|
return setTournamentInfo(data) |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
return redirectToHomePage() |
|
|
|
return redirectToHomePage() |
|
|
|
@ -115,6 +117,28 @@ export const useLandings = () => { |
|
|
|
return () => clearInterval(getSliderInterval) |
|
|
|
return () => clearInterval(getSliderInterval) |
|
|
|
}, [imgCounter, sliderItemId]) |
|
|
|
}, [imgCounter, sliderItemId]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const inActiveLandingData = () => { |
|
|
|
|
|
|
|
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 { |
|
|
|
@ -123,6 +147,7 @@ export const useLandings = () => { |
|
|
|
defaultTournamentName, |
|
|
|
defaultTournamentName, |
|
|
|
description, |
|
|
|
description, |
|
|
|
gallery, |
|
|
|
gallery, |
|
|
|
|
|
|
|
inActiveLandingData, |
|
|
|
isInactiveLanding, |
|
|
|
isInactiveLanding, |
|
|
|
isNonExistLanding, |
|
|
|
isNonExistLanding, |
|
|
|
logo: tournamentInfo?.media.logo, |
|
|
|
logo: tournamentInfo?.media.logo, |
|
|
|
|