import { request } from '../../../utils';
import { API } from '../../../types';
import { ResponseType } from '../response-type';

export interface PostGetSlowReturn extends ResponseType {
  slow: {
    country_id: number;
    country: string;
    flag: string;
    mega: number[];
    visited: 0 | 1;
    slow11: 0 | 1;
    slow31: 0 | 1;
    slow101: 0 | 1;
    yes: number;
  }[];
  megaregions: {
    id: number;
    name: string;
  }[];
}

export interface PostSetSlow {
  token: string;
  id: number;
  v: boolean;
  s11: boolean;
  s31: boolean;
  s101: boolean;
}

export const countriesApi = {
  getSlow: (token: string) => request.postForm<PostGetSlowReturn>(API.GET_SLOW, { token }),
  setSlow: (data: PostSetSlow) => request.postForm<ResponseType>(API.SET_SLOW, data)
};
