From da4f29f41ba5ddf7d5f65436b14f45f6387b6d97 Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Thu, 14 Aug 2025 19:21:02 +0800 Subject: [PATCH] quick update for po detail --- src/components/PoDetail/PoDetail.tsx | 13 +++++++------ src/components/PoDetail/PoInputGrid.tsx | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/PoDetail/PoDetail.tsx b/src/components/PoDetail/PoDetail.tsx index b67d6e9..f49256a 100644 --- a/src/components/PoDetail/PoDetail.tsx +++ b/src/components/PoDetail/PoDetail.tsx @@ -182,7 +182,7 @@ const PoDetail: React.FC = ({ po, qc, warehouse }) => { const searchParams = useSearchParams(); const [row, setRow] = useState(rows[0]); - const [stockInLine, setStockInLine] = useState([]); + const [stockInLine, setStockInLine] = useState(rows[0].stockInLine); const [processedQty, setProcessedQty] = useState(rows[0].processed); const router = useRouter(); @@ -288,9 +288,9 @@ const PoDetail: React.FC = ({ po, qc, warehouse }) => { setRows(purchaseOrder.pol || []); }, [purchaseOrder]); - useEffect(() => { - setStockInLine([]) - }, []); + // useEffect(() => { + // setStockInLine([]) + // }, []); function Row(props: { row: PurchaseOrderLine }) { const { row } = props; @@ -330,15 +330,16 @@ const PoDetail: React.FC = ({ po, qc, warehouse }) => { (id: number) => { console.log(id) //rows = purchaseOrderLine + console.log(rows) const target = rows.find((r) => r.id === id) const stockInLine = target!.stockInLine console.log(stockInLine) - console.log(stockInLine) setStockInLine(stockInLine) + setRow(target!) // console.log(pathname) // router.replace(`/po/edit?id=${item.poId}&polId=${item.polId}&stockInLineId=${item.stockInLineId}`); }, - [] + [rows] ); const handleStart = useCallback( diff --git a/src/components/PoDetail/PoInputGrid.tsx b/src/components/PoDetail/PoInputGrid.tsx index c278f97..008cebf 100644 --- a/src/components/PoDetail/PoInputGrid.tsx +++ b/src/components/PoDetail/PoInputGrid.tsx @@ -121,6 +121,9 @@ function PoInputGrid({ ); console.log(stockInLine); const [entries, setEntries] = useState(stockInLine || []); + useEffect(() => { + setEntries(stockInLine) + }, [stockInLine]) const [modalInfo, setModalInfo] = useState< StockInLine & { qcResult?: PurchaseQcResult[] } >();