import { sendFetch, PageProps } from './index'
import * as URL from "./URL";
import {

    PolygonsAttrib,
} from "./type";

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

}

export interface DrawingDataType extends PolygonsAttrib {
    id?: string;
    polygons: PolyDataType[],
}

export type DrawingParamsType = {
    data: DrawingDataType,
    relicsId: string
    drawingId?: string
}

export const addOrUpdateDrawingFetch = (params: Partial<DrawingParamsType>) =>
    sendFetch<PageProps<DrawingDataType>>(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 } }
    );
