import { PolygonsAttrib } from "drawing-board";
import { sendFetch, PageProps } from "./index";
import * as URL from "./URL";

//
export type PolyDataType = {
  id: string;
  lineIds: string[];
  name?: string;
};

export type DrawingParamsType = {
  data: PolygonsAttrib;
  relicsId: string;
  drawingId?: string;
};

export const addOrUpdateDrawingFetch = (params: Partial<DrawingParamsType>) =>
  sendFetch<PageProps<PolygonsAttrib>>(URL.addOrUpdateDrawing, {
    method: "post",
    body: JSON.stringify(params),
  });

export const getDrawingDetailFetch = (drawingId: string) =>
  sendFetch<PageProps<DrawingParamsType>>(
    URL.getDrawingInfoByRelicsId,
    { method: "post", body: JSON.stringify({}) },
    { paths: { drawingId: drawingId } }
  );
