import { requestClient } from '#/api/request';

export namespace productionApi {
  export interface production {
    id: number;
    org_id: string;
    category_id: number;
    name: string;
    desc: string;
    created_at: string;
    updated_at: string;
  }
  export interface getProductionList {
    list: production[];
  }
  export interface createProduction {
    name: string;
    desc: string;
    category_id: number;
    org_id: string;
  }
  export interface updateProduction {
    name: string;
    desc: string;
    category_id: number;
  }
}

export const getProductionList = async (org_id: string) =>
  requestClient.get<productionApi.getProductionList>(
    '/device-management/products',
    {
      params: {
        org_id,
      },
    },
  );

export const deleteProduction = async (id: number) =>
  requestClient.delete(`/device-management/products/`, {
    params: {
      ids: [id],
    },
  });

export const createProduction = async (data: productionApi.createProduction) =>
  requestClient.post('/device-management/products', data);

export const updateProduction = async (
  id: number,
  data: productionApi.updateProduction,
) => requestClient.put(`/device-management/products/${id}`, data);
