import { API_ROOT } from 'config'

import { callApi } from 'helpers'

export type FavouriteTeamType = {
  country_id?: number,
  season: number,
  sport_id: number,
  tournament_id: number,
}

export type FavouriteTeams = {
  active?: boolean,
  group?: string,
  id: number,
  name_en: string,
  name_ru: string,
}

export type ResponseType = {
  data: Array<FavouriteTeams>,
  msg: string,
  status: string,
}

export const getFavouriteTeam = async ({
  season,
  sport_id,
  tournament_id,
}: FavouriteTeamType): Promise<ResponseType> => {
  const config = {
    method: 'GET',
  }

  return callApi({
    config,
    url: `${API_ROOT}/v1/survey/teams/${sport_id}/${tournament_id}/${season}`,
  })
}
