From 3746c7cd40f0e4c5bfcb8256918fd0799e1f3a34 Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Thu, 21 Aug 2025 18:40:21 +0800 Subject: [PATCH] add escalation combo --- src/app/(main)/po/edit/page.tsx | 4 ++++ src/app/api/po/index.ts | 6 ++++++ src/app/api/user/index.ts | 15 +++++++++++++++ src/components/PoDetail/PoDetailWrapper.tsx | 9 ++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/app/(main)/po/edit/page.tsx b/src/app/(main)/po/edit/page.tsx index f701caf..04ea01a 100644 --- a/src/app/(main)/po/edit/page.tsx +++ b/src/app/(main)/po/edit/page.tsx @@ -1,3 +1,4 @@ +import { fetchEscalationCombo } from "@/app/api/user"; import { SearchParams } from "@/app/utils/fetchUtil"; import { TypeEnum } from "@/app/utils/typeEnum"; import CreateProductMaterial from "@/components/CreateItem"; @@ -22,6 +23,9 @@ const PoEdit: React.FC = async ({ searchParams }) => { if (!id) { notFound(); } + + fetchEscalationCombo() + return ( <> {/* {t("Create Material")} */} diff --git a/src/app/api/po/index.ts b/src/app/api/po/index.ts index a240005..55678b1 100644 --- a/src/app/api/po/index.ts +++ b/src/app/api/po/index.ts @@ -15,6 +15,11 @@ export interface PoResult { estimatedArrivalDate: string; completedDate: string; itemDetail?: string; + itemCode?: string; + itemName?: string; + itemQty?: string; + itemSumAcceptedQty?: string; + itemUom?: string; escalated: boolean; status: string; pol?: PurchaseOrderLine[]; @@ -74,6 +79,7 @@ export interface StockInLine { defaultWarehouseId: number; // id for now dnNo: string; dnDate: number[]; + stockQty: number; } export const fetchPoList = cache(async (queryParams?: Record) => { diff --git a/src/app/api/user/index.ts b/src/app/api/user/index.ts index 19396a7..9d50db2 100644 --- a/src/app/api/user/index.ts +++ b/src/app/api/user/index.ts @@ -31,6 +31,15 @@ export type passwordRule = { specialChar: boolean; }; +export interface EscalationCombo { + id: number; + value: number; + label: string; + name: string; + title: string; + department: string; +} + export const preloadUser = () => { fetchUser(); }; @@ -56,3 +65,9 @@ export const fetchPwRules = cache(async () => { next: { tags: ["pwRule"] }, }); }); + +export const fetchEscalationCombo = cache(async () => { + return serverFetchJson(`${BASE_API_URL}/user/escalation-combo`, { + next: { tags: ["escalationCombo"]} + }) +}) diff --git a/src/components/PoDetail/PoDetailWrapper.tsx b/src/components/PoDetail/PoDetailWrapper.tsx index b5e6db6..3cc27c6 100644 --- a/src/components/PoDetail/PoDetailWrapper.tsx +++ b/src/components/PoDetail/PoDetailWrapper.tsx @@ -10,6 +10,7 @@ import PoDetail from "./PoDetail"; import { QcItemWithChecks } from "@/app/api/qc"; import { fetchWarehouseList } from "@/app/api/warehouse"; import { fetchQcItemCheck } from "@/app/api/qc/actions"; +import { fetchEscalationCombo } from "@/app/api/user"; interface SubComponents { Loading: typeof PoDetailLoading; @@ -20,10 +21,16 @@ type Props = { }; const PoDetailWrapper: React.FC & SubComponents = async ({ id }) => { - const [poWithStockInLine, warehouse, qc] = await Promise.all([ + const [ + poWithStockInLine, + warehouse, + qc, + escalationCombo + ] = await Promise.all([ fetchPoWithStockInLines(id), fetchWarehouseList(), fetchQcItemCheck(), + fetchEscalationCombo(), ]); // const poWithStockInLine = await fetchPoWithStockInLines(id)