|
- import { cache } from "react";
- import "server-only";
- import { serverFetchJson } from "@/app/utils/fetchUtil";
- import { BASE_API_URL } from "@/config/api";
-
- export type ProductResult = {
- id: string | number
- code: string;
- name: string;
- isConsumables: boolean;
- description: string | undefined;
- type: string | undefined;
- remarks: string | undefined;
- shelfLife: Number | undefined;
- countryOfOrigin: string | undefined;
- minHumid: number | undefined;
- maxHumid: number | undefined;
- minTemp: number | undefined;
- maxTemp: number | undefined;
- sampleRate: number | undefined;
- passingRate: number | undefined;
- netWeight: number | undefined;
- uom: string[] | any[];
- weightUnit: string[] | any[];
- action?: any;
- }
-
-
- export const fetchAllMaterials = cache(async () => {
- return serverFetchJson<ProductResult[]>(`${BASE_API_URL}/product`, {
- next: { tags: ["product"] },
- });
- });
-
-
- export const fetchMaterial = cache(async (id: number) => {
- return serverFetchJson<ProductResult>(`${BASE_API_URL}/product/details/${id}`, {
- next: { tags: ["product"] },
- });
- });
|