You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
spa_instat_tv/src/requests/getLanding.tsx

74 lines
1.4 KiB

import isUndefined from 'lodash/isUndefined'
import { API_ROOT } from 'config'
import { callApi } from 'helpers'
type Tournaments = {
season: string,
season_id: number,
sport_eng: string,
sport_id: number,
sport_rus: string,
tournament_eng: string,
tournament_id: number,
tournament_rus: string,
}
type Teams = {
id: number,
logo: string,
name_eng: string,
name_rus: string,
sport_id: number,
}
type Gallery = {
id: string,
url: string,
}
export type Landing = {
button_color?: string,
date_from: string,
date_to: string,
id: number,
lexic_button?: number,
lexic_description?: number,
lexic_period?: number,
lexic_title?: number,
logo_insports: boolean,
logo_team: boolean,
media: {
gallery: Array<Gallery>,
logo: string,
},
name: string,
teams: Array<Teams>,
tournaments: Array<Tournaments> | null,
url_button?: string,
}
type Args = {
landingName: number | string,
seasonId?: number,
sportId?: number,
tournamentId?: number,
}
export const getLanding = async ({
landingName,
seasonId,
sportId,
tournamentId,
}: Args): Promise<Landing> => {
const config = {
method: 'GET',
}
return callApi({
config,
url: `${API_ROOT}/v1/landings/${landingName}${isUndefined(seasonId)
? ''
: `?season_id=${seasonId}&sport_id=${sportId}&tournament_id=${tournamentId}`}`,
})
}