From 5d545487fccb89a284b18d1d0fd9d574ba399950 Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Wed, 21 May 2025 18:33:32 +0800 Subject: [PATCH] update po --- src/components/PoDetail/PoInputGrid.tsx | 61 ++++++++++++++++++++++--- src/components/PoDetail/QcForm.tsx | 2 +- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/components/PoDetail/PoInputGrid.tsx b/src/components/PoDetail/PoInputGrid.tsx index 7690db6..68dd67d 100644 --- a/src/components/PoDetail/PoInputGrid.tsx +++ b/src/components/PoDetail/PoInputGrid.tsx @@ -39,6 +39,13 @@ import { stockInLineStatusMap } from "@/app/utils/formatUtil"; import PoQcStockInModal from "./PoQcStockInModal"; import NotificationImportantIcon from "@mui/icons-material/NotificationImportant"; import { WarehouseResult } from "@/app/api/warehouse"; +import LooksOneIcon from '@mui/icons-material/LooksOne'; +import LooksTwoIcon from '@mui/icons-material/LooksTwo'; +import Looks3Icon from '@mui/icons-material/Looks3'; +import axiosInstance from "@/app/(main)/axios/axiosInstance"; +import axios from "axios"; +import { NEXT_PUBLIC_API_URL } from "@/config/api"; +import QrCodeIcon from '@mui/icons-material/QrCode'; interface ResultWithId { id: number; } @@ -158,13 +165,23 @@ function PoInputGrid({ }, [] ); + const fetchQcDefaultValue = useCallback(async () => { + const authHeader = axiosInstance.defaults.headers['Authorization']; + if (!authHeader) { + return; // Exit the function if the token is not set + } + const res = await axios.get(`${NEXT_PUBLIC_API_URL}/qcResult/${itemDetail.id}`) + console.log(res) + }, [axiosInstance, axios]) + const handleQC = useCallback( - (id: GridRowId, params: any) => () => { + (id: GridRowId, params: any) => async () => { setRowModesModel((prev) => ({ ...prev, [id]: { mode: GridRowModes.View }, })); setModalInfo(params.row); + // await fetchQcDefaultValue() setTimeout(() => { // open qc modal console.log("delayed"); @@ -224,6 +241,24 @@ function PoInputGrid({ [] ); + const handleQrCode = useCallback( + (id: GridRowId, params: any) => () => { + setRowModesModel((prev) => ({ + ...prev, + [id]: { mode: GridRowModes.View }, + })); + setModalInfo(params.row); + setTimeout(() => { + // open stock in modal + // openPutAwayModal(); + // return the record with its status as pending + // update layout + console.log("delayed"); + }, 200); + }, + [] + ); + const closeQcModal = useCallback(() => { setQcOpen(false); }, []); @@ -290,7 +325,7 @@ function PoInputGrid({ label="start" sx={{ color: "primary.main", - marginRight: 2, + // marginRight: 1, }} disabled={!(stockInLineStatusMap[status] === 0)} // set _isNew to false after posting @@ -304,7 +339,7 @@ function PoInputGrid({ label="qc" sx={{ color: "primary.main", - marginRight: 2, + // marginRight: 1, }} disabled={ // stockInLineStatusMap[status] <= 0 || @@ -322,7 +357,7 @@ function PoInputGrid({ label="escalation" sx={{ color: "primary.main", - marginRight: 2, + // marginRight: 1, }} disabled={ stockInLineStatusMap[status] <= 0 || @@ -339,7 +374,7 @@ function PoInputGrid({ label="stockin" sx={{ color: "primary.main", - marginRight: 2, + // marginRight: 1, }} disabled={stockInLineStatusMap[status] !== 6} // set _isNew to false after posting @@ -353,7 +388,7 @@ function PoInputGrid({ label="putaway" sx={{ color: "primary.main", - marginRight: 2, + // marginRight: 1, }} disabled={stockInLineStatusMap[status] !== 7} // set _isNew to false after posting @@ -362,6 +397,20 @@ function PoInputGrid({ color="inherit" key="edit" />, + } + label="putaway" + sx={{ + color: "primary.main", + // marginRight: 1, + }} + disabled={stockInLineStatusMap[status] !== 8} + // set _isNew to false after posting + // or check status + onClick={handleQrCode(params.row.id, params)} + color="inherit" + key="edit" + />, } label="Delete" diff --git a/src/components/PoDetail/QcForm.tsx b/src/components/PoDetail/QcForm.tsx index 3b267fb..33c015e 100644 --- a/src/components/PoDetail/QcForm.tsx +++ b/src/components/PoDetail/QcForm.tsx @@ -65,7 +65,7 @@ const QcForm: React.FC = ({ qc, itemDetail }) => { clearErrors, } = useFormContext(); console.log(itemDetail); - + // const [qc, setQc] = useState([]) // const fetchQcCheck = useCallback(async () => { // const authHeader = axiosInstance.defaults.headers['Authorization'];