Browse Source

update po

create_edit_user
MSI\derek 3 months ago
parent
commit
5d545487fc
2 changed files with 56 additions and 7 deletions
  1. +55
    -6
      src/components/PoDetail/PoInputGrid.tsx
  2. +1
    -1
      src/components/PoDetail/QcForm.tsx

+ 55
- 6
src/components/PoDetail/PoInputGrid.tsx View File

@@ -39,6 +39,13 @@ import { stockInLineStatusMap } from "@/app/utils/formatUtil";
import PoQcStockInModal from "./PoQcStockInModal"; import PoQcStockInModal from "./PoQcStockInModal";
import NotificationImportantIcon from "@mui/icons-material/NotificationImportant"; import NotificationImportantIcon from "@mui/icons-material/NotificationImportant";
import { WarehouseResult } from "@/app/api/warehouse"; 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 { interface ResultWithId {
id: number; 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<QcItemWithChecks[]>(`${NEXT_PUBLIC_API_URL}/qcResult/${itemDetail.id}`)
console.log(res)
}, [axiosInstance, axios])

const handleQC = useCallback( const handleQC = useCallback(
(id: GridRowId, params: any) => () => {
(id: GridRowId, params: any) => async () => {
setRowModesModel((prev) => ({ setRowModesModel((prev) => ({
...prev, ...prev,
[id]: { mode: GridRowModes.View }, [id]: { mode: GridRowModes.View },
})); }));
setModalInfo(params.row); setModalInfo(params.row);
// await fetchQcDefaultValue()
setTimeout(() => { setTimeout(() => {
// open qc modal // open qc modal
console.log("delayed"); 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(() => { const closeQcModal = useCallback(() => {
setQcOpen(false); setQcOpen(false);
}, []); }, []);
@@ -290,7 +325,7 @@ function PoInputGrid({
label="start" label="start"
sx={{ sx={{
color: "primary.main", color: "primary.main",
marginRight: 2,
// marginRight: 1,
}} }}
disabled={!(stockInLineStatusMap[status] === 0)} disabled={!(stockInLineStatusMap[status] === 0)}
// set _isNew to false after posting // set _isNew to false after posting
@@ -304,7 +339,7 @@ function PoInputGrid({
label="qc" label="qc"
sx={{ sx={{
color: "primary.main", color: "primary.main",
marginRight: 2,
// marginRight: 1,
}} }}
disabled={ disabled={
// stockInLineStatusMap[status] <= 0 || // stockInLineStatusMap[status] <= 0 ||
@@ -322,7 +357,7 @@ function PoInputGrid({
label="escalation" label="escalation"
sx={{ sx={{
color: "primary.main", color: "primary.main",
marginRight: 2,
// marginRight: 1,
}} }}
disabled={ disabled={
stockInLineStatusMap[status] <= 0 || stockInLineStatusMap[status] <= 0 ||
@@ -339,7 +374,7 @@ function PoInputGrid({
label="stockin" label="stockin"
sx={{ sx={{
color: "primary.main", color: "primary.main",
marginRight: 2,
// marginRight: 1,
}} }}
disabled={stockInLineStatusMap[status] !== 6} disabled={stockInLineStatusMap[status] !== 6}
// set _isNew to false after posting // set _isNew to false after posting
@@ -353,7 +388,7 @@ function PoInputGrid({
label="putaway" label="putaway"
sx={{ sx={{
color: "primary.main", color: "primary.main",
marginRight: 2,
// marginRight: 1,
}} }}
disabled={stockInLineStatusMap[status] !== 7} disabled={stockInLineStatusMap[status] !== 7}
// set _isNew to false after posting // set _isNew to false after posting
@@ -362,6 +397,20 @@ function PoInputGrid({
color="inherit" color="inherit"
key="edit" key="edit"
/>, />,
<GridActionsCellItem
icon={<QrCodeIcon />}
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"
/>,
<GridActionsCellItem <GridActionsCellItem
icon={<DeleteIcon />} icon={<DeleteIcon />}
label="Delete" label="Delete"


+ 1
- 1
src/components/PoDetail/QcForm.tsx View File

@@ -65,7 +65,7 @@ const QcForm: React.FC<Props> = ({ qc, itemDetail }) => {
clearErrors, clearErrors,
} = useFormContext<PurchaseQCInput>(); } = useFormContext<PurchaseQCInput>();
console.log(itemDetail); console.log(itemDetail);
// const [qc, setQc] = useState<QcItemWithChecks[]>([]) // const [qc, setQc] = useState<QcItemWithChecks[]>([])
// const fetchQcCheck = useCallback(async () => { // const fetchQcCheck = useCallback(async () => {
// const authHeader = axiosInstance.defaults.headers['Authorization']; // const authHeader = axiosInstance.defaults.headers['Authorization'];


Loading…
Cancel
Save