From ecb497430a9f9fcc1973e972cff126be4ab012f0 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 11 Nov 2025 15:05:05 +0700 Subject: [PATCH] feat(FE-208,212): enhance PurchaseOrder forms with onCancel functionality and UI improvements --- .../pages/purchase/PurchaseTable.tsx | 57 ++ .../order/PurchaseOrderAcceptApprovalForm.tsx | 931 +++++++++--------- .../order/PurchaseOrderStaffApprovalForm.tsx | 61 +- 3 files changed, 544 insertions(+), 505 deletions(-) diff --git a/src/components/pages/purchase/PurchaseTable.tsx b/src/components/pages/purchase/PurchaseTable.tsx index 74092ebf..9e10438b 100644 --- a/src/components/pages/purchase/PurchaseTable.tsx +++ b/src/components/pages/purchase/PurchaseTable.tsx @@ -10,6 +10,7 @@ import Table from '@/components/Table'; import DebouncedTextInput from '@/components/input/DebouncedTextInput'; import Button from '@/components/Button'; import { useModal } from '@/components/Modal'; +import Modal from '@/components/Modal'; import ConfirmationModal from '@/components/modal/ConfirmationModal'; import SelectInput, { OptionType, @@ -21,6 +22,8 @@ import TextInput from '@/components/input/TextInput'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import { cn, formatDate, formatCurrency } from '@/lib/helper'; +import PurchaseOrderStaffApprovalForm from '@/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm'; +import PurchaseOrderAcceptApprovalForm from '@/components/pages/purchase/form/order/PurchaseOrderAcceptApprovalForm'; import { isResponseSuccess } from '@/lib/api-helper'; import { useTableFilter } from '@/services/hooks/useTableFilter'; import { ROWS_OPTIONS } from '@/config/constant'; @@ -108,6 +111,8 @@ const PurchaseTable = () => { // Modal hooks const deleteModal = useModal(); + const staffApprovalModal = useModal(); + const acceptApprovalModal = useModal(); // Supplier modal const { @@ -282,6 +287,30 @@ const PurchaseTable = () => { Tambah + + + + {selectedRowIds.length > 0 && ( - + {/* Action buttons */} +
+
+ - -
-
+ + + - {purchaseOrderFormErrorMessage && ( -
- - {purchaseOrderFormErrorMessage} -
- )} - - - - + {purchaseOrderFormErrorMessage && ( +
+ + {purchaseOrderFormErrorMessage} +
+ )} + + ); }; diff --git a/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx b/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx index 8f303b56..805147ba 100644 --- a/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx +++ b/src/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm.tsx @@ -23,16 +23,17 @@ import { Purchase, } from '@/types/api/purchase/purchase'; -import Card from '@/components/Card'; interface PurchaseOrderStaffApprovalFormProps { type?: 'add' | 'edit'; initialValues?: Purchase; + onCancel?: () => void; } const PurchaseOrderStaffApprovalForm = ({ type = 'add', initialValues, + onCancel, }: PurchaseOrderStaffApprovalFormProps) => { const searchParams = useSearchParams(); const [purchaseOrderFormErrorMessage, setPurchaseOrderFormErrorMessage] = @@ -99,6 +100,7 @@ const PurchaseOrderStaffApprovalForm = ({ return; } toast.success(res?.message as string); + onCancel?.(); }, [initialValues?.id, searchParams] ); @@ -117,6 +119,7 @@ const PurchaseOrderStaffApprovalForm = ({ return; } toast.success(res?.message as string); + onCancel?.(); window.location.href = '/purchase'; }, [] @@ -299,18 +302,12 @@ const PurchaseOrderStaffApprovalForm = ({ return ( <> -
-
- + +
+

Konfirmasi Approve Pembelian

@@ -525,11 +522,14 @@ const PurchaseOrderStaffApprovalForm = ({ {/* Action buttons */}
- - - +
- {purchaseOrderFormErrorMessage && ( -
- - {purchaseOrderFormErrorMessage} -
- )} - - - + {purchaseOrderFormErrorMessage && ( +
+ + {purchaseOrderFormErrorMessage} +
+ )} +
+ ); };