mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 14:55:44 +00:00
refactor(FE-208,212): add refreshApprovals and onModalClose props to approval forms
This commit is contained in:
@@ -27,12 +27,16 @@ interface PurchaseOrderAcceptApprovalFormProps {
|
||||
type?: 'add' | 'edit';
|
||||
initialValues?: Purchase;
|
||||
onCancel?: () => void;
|
||||
refreshApprovals?: () => void;
|
||||
onModalClose?: () => void;
|
||||
}
|
||||
|
||||
const PurchaseOrderAcceptApprovalForm = ({
|
||||
type = 'add',
|
||||
initialValues,
|
||||
onCancel,
|
||||
refreshApprovals,
|
||||
onModalClose,
|
||||
}: PurchaseOrderAcceptApprovalFormProps) => {
|
||||
const searchParams = useSearchParams();
|
||||
const [purchaseOrderFormErrorMessage, setPurchaseOrderFormErrorMessage] =
|
||||
@@ -99,9 +103,12 @@ const PurchaseOrderAcceptApprovalForm = ({
|
||||
return;
|
||||
}
|
||||
toast.success(res?.message as string);
|
||||
refreshApprovals?.();
|
||||
formik.resetForm();
|
||||
onCancel?.();
|
||||
onModalClose?.();
|
||||
},
|
||||
[initialValues?.id, searchParams]
|
||||
[initialValues?.id, searchParams, refreshApprovals, onModalClose]
|
||||
);
|
||||
|
||||
const updateAcceptApprovalHandler = useCallback(
|
||||
@@ -112,10 +119,13 @@ const PurchaseOrderAcceptApprovalForm = ({
|
||||
return;
|
||||
}
|
||||
toast.success(res?.message as string);
|
||||
refreshApprovals?.();
|
||||
formik.resetForm();
|
||||
onCancel?.();
|
||||
onModalClose?.();
|
||||
window.location.href = '/purchase';
|
||||
},
|
||||
[]
|
||||
[refreshApprovals, onModalClose]
|
||||
);
|
||||
|
||||
// ===== FORM CONFIGURATION =====
|
||||
@@ -652,7 +662,12 @@ const PurchaseOrderAcceptApprovalForm = ({
|
||||
type='button'
|
||||
color='warning'
|
||||
className='px-4'
|
||||
onClick={onCancel}
|
||||
onClick={() => {
|
||||
formik.resetForm();
|
||||
setPurchaseOrderFormErrorMessage('');
|
||||
onCancel?.();
|
||||
onModalClose?.();
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
@@ -27,12 +27,16 @@ interface PurchaseOrderStaffApprovalFormProps {
|
||||
type?: 'add' | 'edit';
|
||||
initialValues?: Purchase;
|
||||
onCancel?: () => void;
|
||||
refreshApprovals?: () => void;
|
||||
onModalClose?: () => void;
|
||||
}
|
||||
|
||||
const PurchaseOrderStaffApprovalForm = ({
|
||||
type = 'add',
|
||||
initialValues,
|
||||
onCancel,
|
||||
refreshApprovals,
|
||||
onModalClose,
|
||||
}: PurchaseOrderStaffApprovalFormProps) => {
|
||||
const searchParams = useSearchParams();
|
||||
const [purchaseOrderFormErrorMessage, setPurchaseOrderFormErrorMessage] =
|
||||
@@ -90,9 +94,12 @@ const PurchaseOrderStaffApprovalForm = ({
|
||||
return;
|
||||
}
|
||||
toast.success(res?.message as string);
|
||||
refreshApprovals?.();
|
||||
formik.resetForm();
|
||||
onCancel?.();
|
||||
onModalClose?.();
|
||||
},
|
||||
[initialValues?.id, searchParams]
|
||||
[initialValues?.id, searchParams, refreshApprovals, onModalClose]
|
||||
);
|
||||
|
||||
const updateStaffApprovalHandler = useCallback(
|
||||
@@ -106,10 +113,13 @@ const PurchaseOrderStaffApprovalForm = ({
|
||||
return;
|
||||
}
|
||||
toast.success(res?.message as string);
|
||||
refreshApprovals?.();
|
||||
formik.resetForm();
|
||||
onCancel?.();
|
||||
onModalClose?.();
|
||||
await router.push(`/purchase/detail?purchaseId=${purchaseId}`);
|
||||
},
|
||||
[]
|
||||
[refreshApprovals, onModalClose]
|
||||
);
|
||||
|
||||
// ===== FORM CONFIGURATION =====
|
||||
@@ -451,7 +461,12 @@ const PurchaseOrderStaffApprovalForm = ({
|
||||
type='button'
|
||||
color='warning'
|
||||
className='px-4'
|
||||
onClick={onCancel}
|
||||
onClick={() => {
|
||||
formik.resetForm();
|
||||
setPurchaseOrderFormErrorMessage('');
|
||||
onCancel?.();
|
||||
onModalClose?.();
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user