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/getSearchItems.tsx

77 lines
1.2 KiB

import {
DATA_URL,
PROCEDURES,
} from 'config'
import { callApi } from 'helpers'
const proc = PROCEDURES.get_objects
export enum Gender {
MALE = 1,
FEMALE = 2,
}
export type NamedObject = {
id: number,
name_eng: string,
name_rus: string,
}
export type PlayerTypeFromSearch = {
country?: NamedObject,
firstname_eng: string,
firstname_rus: string,
gender?: Gender,
id: number,
lastname_eng: string,
lastname_rus: string,
sport: number,
team?: NamedObject,
}
export type PlayersType = Array<PlayerTypeFromSearch>
type Team = {
country?: NamedObject,
gender?: Gender,
id: number,
name_eng: string,
name_rus: string,
sport: number,
}
type Tournament = {
country?: NamedObject,
gender?: Gender,
id: number,
name_eng: string,
name_rus: string,
sport: number,
}
export type SearchItems = {
players?: PlayersType,
teams?: Array<Team>,
tournaments?: Array<Tournament>,
}
export const getSearchItems = (
searchString: string,
abortSignal?: AbortSignal,
): Promise<SearchItems> => {
const config = {
body: {
params: {
_p_name: searchString,
},
proc,
},
}
return callApi({
abortSignal,
config,
url: DATA_URL,
})
}