feat(ott-193): players matches (#106)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Armen 5 years ago committed by GitHub
parent 234d186b34
commit d7d9266409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/features/Burger/styled.tsx
  2. 1
      src/features/HomePage/hooks.tsx
  3. 2
      src/features/Modal/index.tsx
  4. 33
      src/features/PlayerPage/hooks.tsx
  5. 3
      src/features/PlayerPage/index.tsx
  6. 1
      src/features/TeamPage/hooks.tsx
  7. 1
      src/features/TournamentPage/hooks.tsx
  8. 11
      src/requests/getMatches.tsx

@ -50,4 +50,4 @@ export const StyledBurger = styled.div<{open: boolean}>`
background-size: 100%; background-size: 100%;
background-image: url(/images/userAccount.svg); background-image: url(/images/userAccount.svg);
} }
`; `

@ -25,7 +25,6 @@ export const useHomePage = () => {
date: selectedDateFormatted, date: selectedDateFormatted,
matchStatus: selectedMatchStatus, matchStatus: selectedMatchStatus,
sportType: selectedSportTypeId, sportType: selectedSportTypeId,
teamId: null,
tournamentId: selectedTournamentId, tournamentId: selectedTournamentId,
}).then(setMatches) }).then(setMatches)
}, [ }, [

@ -35,4 +35,4 @@ export const Modal = ({
modalRoot.current as Element, modalRoot.current as Element,
) )
: null : null
}; }

@ -1,9 +1,14 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useSportNameParam, usePageId } from 'hooks'
import type { Matches } from 'requests'
import { getMatches } from 'requests'
import type { PlayerProfile } from 'requests/getPlayerInfo' import type { PlayerProfile } from 'requests/getPlayerInfo'
import { getPlayerInfo } from 'requests/getPlayerInfo' import { getPlayerInfo } from 'requests/getPlayerInfo'
import { useSportNameParam, usePageId } from 'hooks'
import { useLexicsStore } from 'features/LexicsStore' import { useLexicsStore } from 'features/LexicsStore'
import { useHeaderFiltersStore } from 'features/HeaderFilters'
type Firstname = 'firstname_eng' | 'firstname_rus' type Firstname = 'firstname_eng' | 'firstname_rus'
type Lastname = 'lastname_eng' | 'lastname_rus' type Lastname = 'lastname_eng' | 'lastname_rus'
@ -14,6 +19,10 @@ export const usePlayerPage = () => {
const { sportType } = useSportNameParam() const { sportType } = useSportNameParam()
const pageId = usePageId() const pageId = usePageId()
const { suffix, translate } = useLexicsStore() const { suffix, translate } = useLexicsStore()
const {
selectedDateFormatted,
selectedMatchStatus,
} = useHeaderFiltersStore()
const { const {
club_team, club_team,
@ -36,8 +45,30 @@ export const usePlayerPage = () => {
getPlayerInfo(pageId, sportType).then(setPlayerProfile) getPlayerInfo(pageId, sportType).then(setPlayerProfile)
}, [pageId, sportType]) }, [pageId, sportType])
const [matches, setMatches] = useState<Matches>({
broadcast: [],
features: [],
highlights: [],
isVideoSections: false,
})
useEffect(() => {
getMatches({
date: selectedDateFormatted,
matchStatus: selectedMatchStatus,
playerId: pageId,
sportType,
}).then(setMatches)
}, [
pageId,
selectedDateFormatted,
selectedMatchStatus,
sportType,
])
return { return {
infoItems, infoItems,
matches,
name: fullName, name: fullName,
} }
} }

@ -3,12 +3,14 @@ import React, { Fragment } from 'react'
import { ProfileTypes } from 'config' import { ProfileTypes } from 'config'
import { UserFavorites } from 'features/UserFavorites' import { UserFavorites } from 'features/UserFavorites'
import { ProfileCard } from 'features/ProfileCard' import { ProfileCard } from 'features/ProfileCard'
import { Matches } from 'features/Matches'
import { usePlayerPage } from './hooks' import { usePlayerPage } from './hooks'
export const PlayerPage = () => { export const PlayerPage = () => {
const { const {
infoItems, infoItems,
matches,
name, name,
} = usePlayerPage() } = usePlayerPage()
@ -20,6 +22,7 @@ export const PlayerPage = () => {
name={name} name={name}
infoItems={infoItems} infoItems={infoItems}
/> />
<Matches matches={matches} />
</Fragment> </Fragment>
) )
} }

@ -51,7 +51,6 @@ export const useTeamPage = () => {
matchStatus: selectedMatchStatus, matchStatus: selectedMatchStatus,
sportType, sportType,
teamId, teamId,
tournamentId: null,
}).then(setMatches) }).then(setMatches)
}, [ }, [
selectedDateFormatted, selectedDateFormatted,

@ -50,7 +50,6 @@ export const useTournamentPage = () => {
date: selectedDateFormatted, date: selectedDateFormatted,
matchStatus: selectedMatchStatus, matchStatus: selectedMatchStatus,
sportType, sportType,
teamId: null,
tournamentId, tournamentId,
}).then(setMatches) }).then(setMatches)
}, [ }, [

@ -52,9 +52,10 @@ export type Team = {
type Args = { type Args = {
date: string, date: string,
matchStatus: MatchStatuses, matchStatus: MatchStatuses,
playerId?: number | null,
sportType: SportTypes | null, sportType: SportTypes | null,
teamId: number | null, teamId?: number | null,
tournamentId: number | null, tournamentId?: number | null,
} }
export type Matches = { export type Matches = {
@ -67,6 +68,7 @@ export type Matches = {
export const getMatches = async ({ export const getMatches = async ({
date, date,
matchStatus, matchStatus,
playerId,
sportType, sportType,
teamId, teamId,
tournamentId, tournamentId,
@ -75,10 +77,11 @@ export const getMatches = async ({
body: { body: {
params: { params: {
_p_date: date, _p_date: date,
_p_player_id: playerId || null,
_p_sport: sportType, _p_sport: sportType,
_p_stream_status: matchStatus, _p_stream_status: matchStatus,
_p_team_id: teamId, _p_team_id: teamId || null,
_p_tournament_id: tournamentId, _p_tournament_id: tournamentId || null,
}, },
proc, proc,
}, },

Loading…
Cancel
Save