refactor(#260): changed matches proc and response types (#63)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 5 years ago committed by GitHub
parent 1d5b0d5e5b
commit cf7f314328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/config/procedures.tsx
  2. 26
      src/requests/getMatches.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',

@ -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<Content> | null,
name: string,
}
export type Content = {
id: number,
matches: Array<Match>,
name_eng: string,
@ -36,12 +52,12 @@ type Args = {
tournamentId: number,
}
export const getMatches = ({
export const getMatches = async ({
date,
matchStatus,
sportType,
tournamentId,
}: Args): Promise<Array<Item>> => {
}: 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 || []
}

Loading…
Cancel
Save