From 5718539e0cd67224e8c835f4b1f7cedf50d18cc0 Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Fri, 23 May 2025 15:33:36 +0800 Subject: [PATCH] update po --- src/app/api/po/actions.ts | 4 +- src/app/api/po/index.ts | 7 ++- src/components/PoDetail/EscalationForm.tsx | 41 ++++--------- src/components/PoDetail/PoInputGrid.tsx | 1 + src/components/PoDetail/PoQcStockInModal.tsx | 14 +++++ src/components/PoDetail/PutawayForm.tsx | 63 ++++++++++++++++++-- 6 files changed, 89 insertions(+), 41 deletions(-) diff --git a/src/app/api/po/actions.ts b/src/app/api/po/actions.ts index 73fcb9a..9ad00c2 100644 --- a/src/app/api/po/actions.ts +++ b/src/app/api/po/actions.ts @@ -50,8 +50,8 @@ export interface PurchaseQCInput { export interface EscalationInput { status: string handler: string - acceptedQty: number - rejectedQty: number + acceptedQty: number // this is the qty to be escalated + // escalationQty: number } export interface PutawayInput { status: string diff --git a/src/app/api/po/index.ts b/src/app/api/po/index.ts index 4fa6a6e..4e6a055 100644 --- a/src/app/api/po/index.ts +++ b/src/app/api/po/index.ts @@ -39,9 +39,12 @@ export interface StockInLine { acceptedQty: number price: number priceUnit: string - productDate: string - shelfLifeDate: string + productionDate: string + expiryDate: string status: string + supplier: string + lotNo: string + poCode: string } export const fetchPoList = cache(async () => { diff --git a/src/components/PoDetail/EscalationForm.tsx b/src/components/PoDetail/EscalationForm.tsx index 93626d6..98385ee 100644 --- a/src/components/PoDetail/EscalationForm.tsx +++ b/src/components/PoDetail/EscalationForm.tsx @@ -76,9 +76,12 @@ const EscalationForm: React.FC = ({ } }, [itemDetail]) - const acceptedQty = watch("acceptedQty") - const rejectedQty = watch("rejectedQty") + // const acceptedQty = watch("acceptedQty") || 0 + const acceptedQty = watch("acceptedQty") || 0 + // console.log(acceptedQty) + console.log(acceptedQty) + console.log(itemDetail.acceptedQty) useEffect(() => { console.log("triggered") setValue("status", status) @@ -93,7 +96,7 @@ const EscalationForm: React.FC = ({ - {t(`to be processed`)}: {itemDetail.acceptedQty - acceptedQty - rejectedQty} + {t(`to be processed`)}: {itemDetail.acceptedQty - acceptedQty} = ({ spacing={2} sx={{ mt: 0.5 }} > - {/* - - */} = ({ required: "acceptedQty required!", min: 0, valueAsNumber: true, + max: itemDetail.acceptedQty })} - // defaultValue={itemDetail.acceptedQty} - // error={Boolean(errors.handler)} - // helperText={errors.handler?.message} - /> - - - diff --git a/src/components/PoDetail/PoInputGrid.tsx b/src/components/PoDetail/PoInputGrid.tsx index f863d92..dd86171 100644 --- a/src/components/PoDetail/PoInputGrid.tsx +++ b/src/components/PoDetail/PoInputGrid.tsx @@ -98,6 +98,7 @@ function PoInputGrid({ stockInLine, warehouse, }: Props) { + console.log(itemDetail) const { t } = useTranslation("home"); const apiRef = useGridApiRef(); const [rowModesModel, setRowModesModel] = useState({}); diff --git a/src/components/PoDetail/PoQcStockInModal.tsx b/src/components/PoDetail/PoQcStockInModal.tsx index 9b57454..36c6d43 100644 --- a/src/components/PoDetail/PoQcStockInModal.tsx +++ b/src/components/PoDetail/PoQcStockInModal.tsx @@ -161,6 +161,20 @@ const PoQcStockInModal: React.FC = ({ [t, itemDetail] ); + const canSubmit = useMemo(() => { + if (type === "qc") { + // console.log(itemDetail.status) + return formProps.formState.isValid + } + if (type === "stockIn") { + return formProps.formState.isValid + } + if (type === "putaway") { + return formProps.formState.isValid + } + return true + }, [type, itemDetail]) + console.log(canSubmit) return ( <> diff --git a/src/components/PoDetail/PutawayForm.tsx b/src/components/PoDetail/PutawayForm.tsx index 25262da..103fba2 100644 --- a/src/components/PoDetail/PutawayForm.tsx +++ b/src/components/PoDetail/PutawayForm.tsx @@ -113,7 +113,7 @@ const PutawayForm: React.FC = ({ itemDetail, warehouse }) => { - {t("Qc Detail")} + {t("Putaway Detail")} = ({ itemDetail, warehouse }) => { spacing={2} sx={{ mt: 0.5 }} > + + + + + + + + + + + + + + + = ({ itemDetail, warehouse }) => { - + + + + - +