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

export interface PostGetSeries extends ResponseType {
  series: { id: number; name: string; icon: string }[];
  items: {
    id: number;
    series_id: number;
    name: string;
    region: number;
    pointJSON: any;
    polygonJSON: string;
    visited?: 0 | 1;
  }[];
}

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

export interface PostGetSeriesList extends ResponseType {
  data: {
    id: number;
    name: string;
    icon: string;
    count: number;
    new: number;
    score: number;
    icon_png: string;
    count2: number;
  }[]
}

export const seriesApi = {
  getSeries: (token: string | null, regions: string) =>
    request.postForm<PostGetSeries>(API.SERIES, { token, regions }),
  getSeriesGroups: () =>
    request.postForm<PostGetSeriesGroups>(API.SERIES_GROUPS),
  getSeriesWithGroup: (token: string, group: string) =>
    request.postForm<PostGetSeriesList>(API.SERIES_WITH_GROUP, { token, group }),
};
