import { PaginatedResponse } from "../types/api-response"; import { Mapset, MapsetSubmitPayload } from "../types/mapset"; import { apiHelpers } from "./api"; const mapsetApi = { getMapsets: async (params?: { filter?: string | string[]; limit?: number; offset?: number; sort?: string }, options?: { skipAuth?: boolean }): Promise> => { const filteredParams = { ...params }; if (!filteredParams.sort) { delete filteredParams.sort; } return apiHelpers.get("/mapsets", { params: filteredParams, paramsSerializer: { indexes: null, }, headers: options?.skipAuth ? { "X-Skip-Auth": "true" } : undefined, }); }, getMapsetById: async (id: string, options?: { skipAuth?: boolean }): Promise => { return apiHelpers.get(`/mapsets/${id}`, { headers: options?.skipAuth ? { "X-Skip-Auth": "true" } : undefined, }); }, getAllMapsets: async (): Promise => { const response = await mapsetApi.getMapsets(); return response.items; }, deleteMapset: async (id?: string): Promise> => { return apiHelpers.delete(`/mapsets/${id}`); }, createMapset: async (mapset: Omit): Promise => { return apiHelpers.post("/mapsets", mapset); }, updateMapset: async (id: string, mapset: Partial): Promise => { return apiHelpers.patch(`/mapsets/${id}`, mapset); }, updateMapsetStatus: async (id: string, status: string, notes: string, layer_url: string): Promise => { return apiHelpers.patch(`/mapsets/${id}`, { status_validation: status, notes: notes, layer_url, }); }, bulkDeactivate: async (mapsetIds: string[]): Promise => { return apiHelpers.patch("/mapsets/activation", { ids: mapsetIds, is_active: false, }); }, }; export default mapsetApi;