"use server";
// import { ServerFetchError, serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
import { serverFetchJson } from "../../../utils/fetchUtil";
import { revalidateTag } from "next/cache";
//import { BASE_API_URL } from "@/config/api";
import { BASE_API_URL } from "../../../../config/api";
import { CreateItemResponse } from "../../utils";
import { ItemQc } from "../item";

export type QcChecksInputs = {} & Partial<ItemQc>;

export const saveItemQcChecks = async (data: QcChecksInputs[]) => {
  // try {
  const res = await serverFetchJson<CreateItemResponse<QcChecksInputs>>(
    `${BASE_API_URL}/qcCheck/new`,
    {
      method: "POST",
      body: JSON.stringify(data),
      headers: { "Content-Type": "application/json" },
    },
  );
  revalidateTag("items");
  return res;
};
