"use server"; import { ServerFetchError, serverFetchJson, serverFetchWithNoContent, } from "@/app/utils/fetchUtil"; import { revalidateTag } from "next/cache"; import { BASE_API_URL } from "@/config/api"; import { CreateItemResponse } from "../../utils"; import { ItemQc } from "."; import { QcChecksInputs } from "../qcCheck/actions"; // export type TypeInputs = { // id: number; // name: string // } // export type UomInputs = { // uom: string // } // export type WeightUnitInputs = { // weightUnit: string // conversion: number // } export type CreateItemInputs = { id?: string | number; code: string; name: string; description?: string | undefined; remarks?: string | undefined; shelfLife?: number | undefined; countryOfOrigin?: string | undefined; maxQty: number; type: string; qcChecks: QcChecksInputs[]; qcChecks_active: number[]; }; export const saveItem = async (data: CreateItemInputs) => { const item = await serverFetchJson>( `${BASE_API_URL}/items/new`, { method: "POST", body: JSON.stringify(data), headers: { "Content-Type": "application/json" }, }, ); revalidateTag("items"); return item; };