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

const proc = PROCEDURES.get_tournament_info

export type TournamentInfo = {
  country: {
    id: number,
    name_eng: string,
    name_rus: string,
  },
  header_image: string | null,
  id: number,
  is_favorite: boolean,
  name_eng: string,
  name_rus: string,
  short_name_eng: string,
  short_name_rus: string,
} | null

export const getTournamentInfo = (sportId: number, tournamentId: number)
: Promise<TournamentInfo> => {
  const config = {
    body: {
      params: {
        _p_sport: sportId,
        _p_tournament_id: tournamentId,
      },
      proc,
    },
  }

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