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 TournamentLanding = {
  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>,
  url_button?: string,
}

export const getTournamentLanding = async (
  landingName: number | string,
): Promise<TournamentLanding> => {
  const config = {
    method: 'GET',
  }

  return callApi({
    config,
    url: `${API_ROOT}/v1/landings/${landingName}`,
  })
}
