import {
  DATA_URL,
  PROCEDURES,
} from 'config'
import { callApi } from 'helpers'

const proc = PROCEDURES.get_sport_teams

export type Team = {
  c_country?: number,
  c_gender?: number,
  c_sport?: number,
  c_team_type?: number,
  country_en?: string,
  country_iso?: string,
  country_ru?: string,
  dl?: boolean,
  id: number,
  name_eng: string,
  name_national: string,
  name_rus: string,
  short_name_eng?: string,
  short_name_rus?: string,
  ts: string,
}

export type SportTeamsType = {
  data: Array<Team>,
  more: boolean,
}
export const getSportTeams = (
  sport_id: number,
  _p_limit: number,
  _p_name: string,
)
: Promise<SportTeamsType> => {
  const config = {
    body: {
      params: {
        _p_limit,
        _p_name,
        sport_id,
      },
      proc,
    },
  }

  return callApi({
    config,
    url: DATA_URL,
  })
}
