diff --git a/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx b/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx index d967b300..02421c5f 100644 --- a/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx +++ b/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx @@ -43,7 +43,7 @@ const PurchaseOrderStaffApprovalForm = ({ if (!initialValues?.approval) return false; const currentStep = initialValues.approval.step_number; - return currentStep >= 4; + return currentStep >= 3; }, [initialValues?.approval]); const getPurchaseItemError = ( @@ -127,7 +127,7 @@ const PurchaseOrderStaffApprovalForm = ({ onSubmit: async (values) => { if (type === 'edit' && !canUpdatePurchaseItems) { setPurchaseOrderFormErrorMessage( - 'Tidak bisa diupdate. Harus melewati step 4 dahulu (Tahapan Penerimaan Produk).' + 'Tidak bisa diupdate. Harus melewati step 3 dahulu (Approval dari Manager Purchasing).' ); return; } diff --git a/src/components/pages/purchase/order/PurchaseOrderDetail.tsx b/src/components/pages/purchase/order/PurchaseOrderDetail.tsx index d56b63da..780353d6 100644 --- a/src/components/pages/purchase/order/PurchaseOrderDetail.tsx +++ b/src/components/pages/purchase/order/PurchaseOrderDetail.tsx @@ -113,6 +113,20 @@ const PurchaseOrderDetail = ({ return currentStep >= 4; }, [initialValues?.approval]); + const canShowPurchaseOrderInvoice = useMemo(() => { + if (!initialValues?.approval) return false; + + const currentStep = initialValues.approval.step_number; + return currentStep >= 3; + }, [initialValues?.approval]); + + const canShowPenerimaanBarang = useMemo(() => { + if (!initialValues?.approval) return false; + + const currentStep = initialValues.approval.step_number; + return currentStep === 5; + }, [initialValues?.approval]); + const { approvals, isLoading: approvalsLoading, @@ -162,6 +176,17 @@ const PurchaseOrderDetail = ({ [initialValues?.id, searchParams] ); + // ===== MODAL HANDLERS ===== + const handleStaffApprovalModalClose = useCallback(() => { + refreshApprovals(); + staffApprovalModal.closeModal(); + }, [refreshApprovals]); + + const handleEditModalClose = useCallback(() => { + refreshApprovals(); + editModal.closeModal(); + }, [refreshApprovals]); + // ===== DELETE HANDLER ===== const deleteItemsHandler = useCallback(async () => { const purchaseRequestId = searchParams.get('purchaseId') @@ -197,7 +222,7 @@ const PurchaseOrderDetail = ({ : `Berhasil menghapus ${itemIdsToDelete.length} item pembelian`; toast.success(successMessage); - + refreshApprovals(); deleteModal.closeModal(); setSelectedItem(null); setRowSelection({}); @@ -574,7 +599,7 @@ const PurchaseOrderDetail = ({ Nomor PO