|
- import { serverFetchJson } from "@/app/utils/fetchUtil";
- import { BASE_API_URL } from "@/config/api";
- import { cache } from "react";
- import "server-only";
- import { SaveQcItemInputs } from "./actions";
- import next from "next";
-
- export interface QcItemResult {
- id: number;
- code: string;
- name: string;
- description: string;
- }
-
- export const preloadQcItem = () => {
- fetchQcItems();
- };
-
- export const fetchQcItems = cache(async () => {
- return serverFetchJson<QcItemResult[]>(`${BASE_API_URL}/qcItems`, {
- next: { tags: ["qcItems"] }
- });
- });
-
- export const fetchQcItemDetail = cache(async (qcItemId: string) => {
- return serverFetchJson<SaveQcItemInputs>(
- `${BASE_API_URL}/qcItems/qcItemDetail/${qcItemId}`,
- {
- next: { tags: [`qcItemDetail_${qcItemId}`] }
- }
- )
- })
|