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

export interface PostGetRegionsReturn extends ResponseType {
  data: { id: number; name: string; flag: string }[];
}

export interface PostGetUserDataReturn extends ResponseType {
  first_visit_year: boolean;
  last_visit_year: boolean;
  no_of_visits: number;
  best_visit_quality: number;
}

export interface PostGetUserDataDareReturn extends ResponseType {
  visited: boolean;
  first_visit_year: boolean;
}

export const regionsApi = {
  getRegionsWithFlag: () => request.postForm<PostGetRegionsReturn>(API.GET_REGIONS_WITH_FLAGS),
  getUserData: (region_id: number, token: string) =>
    request.postForm<PostGetUserDataReturn>(API.GET_USER_DATA, { region_id, token }),
  getUserDataDare: (dare_id: number, token: string) =>
    request.postForm<PostGetUserDataDareReturn>(API.GET_USER_DATA_DARE, { dare_id, token })
};
