|
- "use server";
- import { BASE_API_URL } from "@/config/api";
- // import { ServerFetchError, serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
- import { revalidateTag } from "next/cache";
- import { cache } from "react";
- import { PoResult, StockInLine } from ".";
- import { serverFetchJson } from "@/app/utils/fetchUtil";
- // import { BASE_API_URL } from "@/config/api";
-
- export interface PostStockInLiineResponse<T> {
- id: number | null;
- name: string;
- code: string;
- message: string | null;
- errorPosition: string | keyof T;
- entity: StockInLine | StockInLine[]
- }
-
-
- export interface StockInLineEntry {
- id?: number
- itemId: number
- purchaseOrderId: number
- purchaseOrderLineId: number
- acceptedQty: number
- status?: string
- }
-
- export interface PurchaseQcCheck {
- qcCheckId: number;
- qty: number;
- }
-
- export interface PurchaseQCInput {
- sampleRate: number;
- sampleWeight: number;
- totalWeight: number;
- qcCheck: PurchaseQcCheck[];
- }
-
- export const testFetch = cache(async (id: number) => {
- return serverFetchJson<PoResult>(`${BASE_API_URL}/po/detail/${id}`, {
- next: { tags: ["po"] },
- });
- });
-
- export const createStockInLine = async (data: StockInLineEntry) => {
- const stockInLine = await serverFetchJson<PostStockInLiineResponse<StockInLineEntry>>(`${BASE_API_URL}/stockInLine/create`, {
- method: "POST",
- body: JSON.stringify(data),
- headers: { "Content-Type": "application/json" },
- });
- return stockInLine
- }
-
- export const updateStockInLine = async (data: StockInLineEntry) => {
- const stockInLine = await serverFetchJson<PostStockInLiineResponse<StockInLineEntry>>(`${BASE_API_URL}/stockInLine/update`, {
- method: "POST",
- body: JSON.stringify(data),
- headers: { "Content-Type": "application/json" },
- });
- return stockInLine
- }
-
|