import { cache } from "react";
import "server-only";
// import { serverFetchJson } from "@/app/utils/fetchUtil";
// import { BASE_API_URL } from "@/config/api";
import { serverFetchJson } from "../../../utils/fetchUtil";
import { BASE_API_URL } from "../../../../config/api";
export { default } from "../../../../components/CreateEquipmentType/CreateEquipmentType";
// import { TypeInputs, UomInputs, WeightUnitInputs } from "./actions";

export type EquipmentTypeResultResponse = {
  records: EquipmentTypeResult[];
  total: number;
}

export type EquipmentTypeResult = {
  id: string | number;
  code: string;
  name: string;
  description: string | undefined;
  action?: any;
};

export type Result = {
  equipmentType: EquipmentTypeResult;
};
export const fetchAllEquipmentTypes = cache(async () => {
  return serverFetchJson<EquipmentTypeResult[]>(
    `${BASE_API_URL}/EquipmentType`,
    {
      next: { tags: ["equipmentTypes"] },
    },
  );
});

export const fetchEquipmentType = cache(async (id: number) => {
  return serverFetchJson<EquipmentTypeResult>(
    `${BASE_API_URL}/EquipmentType/details/${id}`,
    {
      next: { tags: ["equipmentTypes"] },
    },
  );
});
