From cf7f314328b7730e509f775a82efe084a6b9d588 Mon Sep 17 00:00:00 2001 From: Mirlan Date: Wed, 29 Jul 2020 14:53:25 +0600 Subject: [PATCH] refactor(#260): changed matches proc and response types (#63) --- src/config/procedures.tsx | 2 +- src/requests/getMatches.tsx | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/config/procedures.tsx b/src/config/procedures.tsx index 4df235fa..b81749b8 100644 --- a/src/config/procedures.tsx +++ b/src/config/procedures.tsx @@ -2,7 +2,7 @@ export const PROCEDURES = { auth_user: 'auth_user', create_user: 'create_user', get_cities: 'get_cities', - get_matches: 'get_matches', + get_matches: 'get_matches_tmp', get_players_teams_tournaments: 'get_players_teams_tournaments', get_sport_list: 'get_sport_list', get_tournament_list: 'get_tournament_list', diff --git a/src/requests/getMatches.tsx b/src/requests/getMatches.tsx index e10a66cd..efc0bd44 100644 --- a/src/requests/getMatches.tsx +++ b/src/requests/getMatches.tsx @@ -5,7 +5,23 @@ import { MatchStatuses } from 'features/HeaderFilters' const proc = PROCEDURES.get_matches -export type Item = { +export type Data = { + is_video_sections: boolean, + video_content: VideoContent, +} + +export type VideoContent = { + broadcast: Items, + features: Items, + highlights: Items, +} + +export type Items = { + content: Array | null, + name: string, +} + +export type Content = { id: number, matches: Array, name_eng: string, @@ -36,12 +52,12 @@ type Args = { tournamentId: number, } -export const getMatches = ({ +export const getMatches = async ({ date, matchStatus, sportType, tournamentId, -}: Args): Promise> => { +}: Args) => { const config = { body: { params: { @@ -54,8 +70,10 @@ export const getMatches = ({ }, } - return callApi({ + const data: Data = await callApi({ config, url: DATA_URL, }).then(getResponseData(proc)) + + return data.video_content.broadcast.content || [] }