From d7d9266409718b80bd02cd65dcf394d1491e3e3b Mon Sep 17 00:00:00 2001 From: Armen <35077035+Armen9393@users.noreply.github.com> Date: Thu, 27 Aug 2020 16:45:57 +0300 Subject: [PATCH] feat(ott-193): players matches (#106) --- src/features/Burger/styled.tsx | 2 +- src/features/HomePage/hooks.tsx | 1 - src/features/Modal/index.tsx | 2 +- src/features/PlayerPage/hooks.tsx | 33 ++++++++++++++++++++++++++- src/features/PlayerPage/index.tsx | 3 +++ src/features/TeamPage/hooks.tsx | 1 - src/features/TournamentPage/hooks.tsx | 1 - src/requests/getMatches.tsx | 11 +++++---- 8 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/features/Burger/styled.tsx b/src/features/Burger/styled.tsx index 86febab4..58b28480 100644 --- a/src/features/Burger/styled.tsx +++ b/src/features/Burger/styled.tsx @@ -50,4 +50,4 @@ export const StyledBurger = styled.div<{open: boolean}>` background-size: 100%; background-image: url(/images/userAccount.svg); } -`; +` diff --git a/src/features/HomePage/hooks.tsx b/src/features/HomePage/hooks.tsx index 814a59aa..5cc3db21 100644 --- a/src/features/HomePage/hooks.tsx +++ b/src/features/HomePage/hooks.tsx @@ -25,7 +25,6 @@ export const useHomePage = () => { date: selectedDateFormatted, matchStatus: selectedMatchStatus, sportType: selectedSportTypeId, - teamId: null, tournamentId: selectedTournamentId, }).then(setMatches) }, [ diff --git a/src/features/Modal/index.tsx b/src/features/Modal/index.tsx index 7315aaba..db17913e 100644 --- a/src/features/Modal/index.tsx +++ b/src/features/Modal/index.tsx @@ -35,4 +35,4 @@ export const Modal = ({ modalRoot.current as Element, ) : null -}; +} diff --git a/src/features/PlayerPage/hooks.tsx b/src/features/PlayerPage/hooks.tsx index 16233ab1..1828fac7 100644 --- a/src/features/PlayerPage/hooks.tsx +++ b/src/features/PlayerPage/hooks.tsx @@ -1,9 +1,14 @@ 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 { getPlayerInfo } from 'requests/getPlayerInfo' -import { useSportNameParam, usePageId } from 'hooks' + import { useLexicsStore } from 'features/LexicsStore' +import { useHeaderFiltersStore } from 'features/HeaderFilters' type Firstname = 'firstname_eng' | 'firstname_rus' type Lastname = 'lastname_eng' | 'lastname_rus' @@ -14,6 +19,10 @@ export const usePlayerPage = () => { const { sportType } = useSportNameParam() const pageId = usePageId() const { suffix, translate } = useLexicsStore() + const { + selectedDateFormatted, + selectedMatchStatus, + } = useHeaderFiltersStore() const { club_team, @@ -36,8 +45,30 @@ export const usePlayerPage = () => { getPlayerInfo(pageId, sportType).then(setPlayerProfile) }, [pageId, sportType]) + const [matches, setMatches] = useState({ + broadcast: [], + features: [], + highlights: [], + isVideoSections: false, + }) + + useEffect(() => { + getMatches({ + date: selectedDateFormatted, + matchStatus: selectedMatchStatus, + playerId: pageId, + sportType, + }).then(setMatches) + }, [ + pageId, + selectedDateFormatted, + selectedMatchStatus, + sportType, + ]) + return { infoItems, + matches, name: fullName, } } diff --git a/src/features/PlayerPage/index.tsx b/src/features/PlayerPage/index.tsx index 9cdb76d1..40aa6a34 100644 --- a/src/features/PlayerPage/index.tsx +++ b/src/features/PlayerPage/index.tsx @@ -3,12 +3,14 @@ import React, { Fragment } from 'react' import { ProfileTypes } from 'config' import { UserFavorites } from 'features/UserFavorites' import { ProfileCard } from 'features/ProfileCard' +import { Matches } from 'features/Matches' import { usePlayerPage } from './hooks' export const PlayerPage = () => { const { infoItems, + matches, name, } = usePlayerPage() @@ -20,6 +22,7 @@ export const PlayerPage = () => { name={name} infoItems={infoItems} /> + ) } diff --git a/src/features/TeamPage/hooks.tsx b/src/features/TeamPage/hooks.tsx index 8a257c48..32b3d0d2 100644 --- a/src/features/TeamPage/hooks.tsx +++ b/src/features/TeamPage/hooks.tsx @@ -51,7 +51,6 @@ export const useTeamPage = () => { matchStatus: selectedMatchStatus, sportType, teamId, - tournamentId: null, }).then(setMatches) }, [ selectedDateFormatted, diff --git a/src/features/TournamentPage/hooks.tsx b/src/features/TournamentPage/hooks.tsx index 88e4bf6a..878c71ed 100644 --- a/src/features/TournamentPage/hooks.tsx +++ b/src/features/TournamentPage/hooks.tsx @@ -50,7 +50,6 @@ export const useTournamentPage = () => { date: selectedDateFormatted, matchStatus: selectedMatchStatus, sportType, - teamId: null, tournamentId, }).then(setMatches) }, [ diff --git a/src/requests/getMatches.tsx b/src/requests/getMatches.tsx index efabec69..5b6644d4 100644 --- a/src/requests/getMatches.tsx +++ b/src/requests/getMatches.tsx @@ -52,9 +52,10 @@ export type Team = { type Args = { date: string, matchStatus: MatchStatuses, + playerId?: number | null, sportType: SportTypes | null, - teamId: number | null, - tournamentId: number | null, + teamId?: number | null, + tournamentId?: number | null, } export type Matches = { @@ -67,6 +68,7 @@ export type Matches = { export const getMatches = async ({ date, matchStatus, + playerId, sportType, teamId, tournamentId, @@ -75,10 +77,11 @@ export const getMatches = async ({ body: { params: { _p_date: date, + _p_player_id: playerId || null, _p_sport: sportType, _p_stream_status: matchStatus, - _p_team_id: teamId, - _p_tournament_id: tournamentId, + _p_team_id: teamId || null, + _p_tournament_id: tournamentId || null, }, proc, },