FPSMS-frontend
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

45 wiersze
1.2 KiB

  1. "use server";
  2. import { ServerFetchError, serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
  3. import { revalidateTag } from "next/cache";
  4. import { BASE_API_URL } from "@/config/api";
  5. import { CreateItemResponse } from "../../utils";
  6. import { ItemQc } from ".";
  7. import { QcChecksInputs } from "../qcCheck/actions";
  8. // export type TypeInputs = {
  9. // id: number;
  10. // name: string
  11. // }
  12. // export type UomInputs = {
  13. // uom: string
  14. // }
  15. // export type WeightUnitInputs = {
  16. // weightUnit: string
  17. // conversion: number
  18. // }
  19. export type CreateItemInputs = {
  20. id?: string | number
  21. code: string;
  22. name: string;
  23. description?: string | undefined;
  24. remarks?: string | undefined;
  25. shelfLife?: Number | undefined;
  26. countryOfOrigin?: string | undefined;
  27. maxQty: number;
  28. type: string;
  29. qcChecks: QcChecksInputs[]
  30. qcChecks_active: number[]
  31. }
  32. export const saveItem = async (data: CreateItemInputs) => {
  33. // try {
  34. const item = await serverFetchJson<CreateItemResponse<CreateItemInputs>>(`${BASE_API_URL}/items/new`, {
  35. method: "POST",
  36. body: JSON.stringify(data),
  37. headers: { "Content-Type": "application/json" },
  38. });
  39. revalidateTag("items");
  40. return item
  41. };