feat(#2973): add landing for tournaments

keep-around/3d3716c8eecddecc93aa1855ad3f52b67b2f7b4b
Andrei Dekterev 3 years ago
parent d6e6644a0a
commit ed54d44ca4
  1. 4
      src/features/App/index.tsx
  2. 2
      src/features/AuthStore/hooks/useAuth.tsx
  3. 18
      src/features/JoinMatchPage/hooks.tsx
  4. 9
      src/features/JoinMatchPage/index.tsx
  5. 22
      src/requests/getUnauthenticatedMatch.tsx

@ -19,13 +19,15 @@ import { JoinMatchPage } from 'features/JoinMatchPage'
import { JoinMatchPageRFEF } from 'features/JoinMatchPageRFEF' import { JoinMatchPageRFEF } from 'features/JoinMatchPageRFEF'
import { AuthenticatedApp } from './AuthenticatedApp' import { AuthenticatedApp } from './AuthenticatedApp'
import { checkPage } from '../../helpers/checkPage'
import { PAGES } from '../../config'
setClientTitleAndDescription(client.title, client.description) setClientTitleAndDescription(client.title, client.description)
const Main = () => { const Main = () => {
const { loadingUser, user } = useAuthStore() const { loadingUser, user } = useAuthStore()
if (!user && isMatchPage()) return <JoinMatchPage /> if (!user && (isMatchPage() || checkPage(PAGES.tournament))) return <JoinMatchPage />
if (!user && isMatchPageRFEF()) return <JoinMatchPageRFEF /> if (!user && isMatchPageRFEF()) return <JoinMatchPageRFEF />
if (user && isMatchPageRFEF()) { if (user && isMatchPageRFEF()) {

@ -67,6 +67,7 @@ export const useAuth = () => {
}, []) }, [])
const checkUser = useCallback(async () => { const checkUser = useCallback(async () => {
if (!user) return null
const loadedUser = await userManager.getUser() const loadedUser = await userManager.getUser()
if (!loadedUser) return Promise.reject() if (!loadedUser) return Promise.reject()
@ -77,6 +78,7 @@ export const useAuth = () => {
userManager, userManager,
storeUser, storeUser,
markUserLoaded, markUserLoaded,
user,
]) ])
const [page, setPage] = useLocalStore({ const [page, setPage] = useLocalStore({

@ -21,17 +21,27 @@ export const useUnauthenticatedMatch = () => {
matchInfo, setMatchInfo, matchInfo, setMatchInfo,
] = useState<UnauthenticatedMatch>(null) ] = useState<UnauthenticatedMatch>(null)
const { profileId: matchId, sportType } = usePageParams() const {
profileId: matchId,
profileType,
sportType,
} = usePageParams()
const matchDate = matchInfo?.date const matchDate = matchInfo?.date
? format(parseDate(matchInfo.date), 'd MMM HH:mm') ? format(parseDate(matchInfo.date), 'd MMM HH:mm')
: '' : ''
useEffect(() => { useEffect(() => {
if (sportType && matchId) getUnauthenticatedMatch(sportType, matchId).then(setMatchInfo) if (sportType && matchId) {
getUnauthenticatedMatch(
sportType,
matchId,
profileType,
)
.then(setMatchInfo)
}
return () => setMatchInfo(null) return () => setMatchInfo(null)
}, [sportType, matchId]) }, [sportType, matchId, profileType])
return { return {
live: matchInfo?.live, live: matchInfo?.live,

@ -54,6 +54,8 @@ export const JoinMatchPage = () => {
<BlockWrapper> <BlockWrapper>
<SportImgWrapper sportType={sportType} /> <SportImgWrapper sportType={sportType} />
<MatchInfo> <MatchInfo>
{matchInfo?.team1
&& (
<DateInfoWrapper> <DateInfoWrapper>
<DateInfo>{matchDate}</DateInfo> <DateInfo>{matchDate}</DateInfo>
{live && ( {live && (
@ -65,10 +67,17 @@ export const JoinMatchPage = () => {
</WatchLive> </WatchLive>
)} )}
</DateInfoWrapper> </DateInfoWrapper>
)}
<TeamsNameWrapper> <TeamsNameWrapper>
{matchInfo?.team1 ? (
<>
<Name nameObj={matchInfo?.team1 || {}} /> <Name nameObj={matchInfo?.team1 || {}} />
<EmptySpan> </EmptySpan> <EmptySpan> </EmptySpan>
<Name nameObj={matchInfo?.team2 || {}} /> <Name nameObj={matchInfo?.team2 || {}} />
</>
) : (<Name nameObj={matchInfo?.tournament || {}} />)}
</TeamsNameWrapper> </TeamsNameWrapper>
<MainInfoTitle> <MainInfoTitle>
<T9n t='join_instat_tv' /> <T9n t='join_instat_tv' />

@ -1,6 +1,7 @@
import { import {
DATA_URL, DATA_URL,
PROCEDURES, PROCEDURES,
ProfileTypes,
SportTypes, SportTypes,
} from 'config' } from 'config'
@ -14,23 +15,32 @@ type Team = {
} }
export type UnauthenticatedMatch = { export type UnauthenticatedMatch = {
date: string, date?: string,
live: boolean, live?: boolean,
team1: Team, team1?: Team,
team2: Team, team2?: Team,
tournament: { tournament: {
name_eng: string, name_eng: string,
name_rus: string, name_rus: string,
}, },
} | null } | null
export const getUnauthenticatedMatch = (sportId: SportTypes, matchId: number) export const getUnauthenticatedMatch = (
sportId: SportTypes,
matchId: number,
profileType?: ProfileTypes,
)
: Promise<UnauthenticatedMatch> => { : Promise<UnauthenticatedMatch> => {
const config = { const config = {
body: { body: {
params: { params: {
_p_match_id: matchId, _p_match_id: profileType === ProfileTypes.MATCHES
? matchId
: null,
_p_sport: sportId, _p_sport: sportId,
_p_tournament_id: profileType === ProfileTypes.TOURNAMENTS
? matchId
: null,
}, },
proc, proc,
}, },

Loading…
Cancel
Save