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. 37
      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 { AuthenticatedApp } from './AuthenticatedApp'
import { checkPage } from '../../helpers/checkPage'
import { PAGES } from '../../config'
setClientTitleAndDescription(client.title, client.description)
const Main = () => {
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()) {

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

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

@ -54,21 +54,30 @@ export const JoinMatchPage = () => {
<BlockWrapper>
<SportImgWrapper sportType={sportType} />
<MatchInfo>
<DateInfoWrapper>
<DateInfo>{matchDate}</DateInfo>
{live && (
<WatchLive>
<WatchLiveCircle />
<WatchLiveText>
<T9n t='watch_live' />
</WatchLiveText>
</WatchLive>
)}
</DateInfoWrapper>
{matchInfo?.team1
&& (
<DateInfoWrapper>
<DateInfo>{matchDate}</DateInfo>
{live && (
<WatchLive>
<WatchLiveCircle />
<WatchLiveText>
<T9n t='watch_live' />
</WatchLiveText>
</WatchLive>
)}
</DateInfoWrapper>
)}
<TeamsNameWrapper>
<Name nameObj={matchInfo?.team1 || {}} />
<EmptySpan> </EmptySpan>
<Name nameObj={matchInfo?.team2 || {}} />
{matchInfo?.team1 ? (
<>
<Name nameObj={matchInfo?.team1 || {}} />
<EmptySpan> </EmptySpan>
<Name nameObj={matchInfo?.team2 || {}} />
</>
) : (<Name nameObj={matchInfo?.tournament || {}} />)}
</TeamsNameWrapper>
<MainInfoTitle>
<T9n t='join_instat_tv' />

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

Loading…
Cancel
Save