mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE): Compute item total on qty change and limit reset
This commit is contained in:
@@ -633,8 +633,18 @@ const PurchaseOrderStaffApprovalForm = ({
|
|||||||
|
|
||||||
formik.setFieldValue(`items.${idx}.qty`, numValue);
|
formik.setFieldValue(`items.${idx}.qty`, numValue);
|
||||||
|
|
||||||
formik.setFieldValue(`items.${idx}.price`, '');
|
if (
|
||||||
formik.setFieldValue(`items.${idx}.total_price`, '');
|
formItem.price !== '' &&
|
||||||
|
formItem.price !== undefined &&
|
||||||
|
formItem.price !== null &&
|
||||||
|
numValue !== '' &&
|
||||||
|
numValue > 0
|
||||||
|
) {
|
||||||
|
const calculatedTotal = Number(formItem.price) * Number(numValue);
|
||||||
|
formik.setFieldValue(`items.${idx}.total_price`, calculatedTotal);
|
||||||
|
} else if (numValue === '') {
|
||||||
|
formik.setFieldValue(`items.${idx}.total_price`, '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field === 'price' || field === 'total_price') {
|
if (field === 'price' || field === 'total_price') {
|
||||||
@@ -1184,8 +1194,10 @@ const PurchaseOrderStaffApprovalForm = ({
|
|||||||
color='warning'
|
color='warning'
|
||||||
className='px-4'
|
className='px-4'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
formik.setValues(formikInitialValues);
|
if (type === 'add') {
|
||||||
formik.resetForm();
|
formik.setValues(formikInitialValues);
|
||||||
|
formik.resetForm();
|
||||||
|
}
|
||||||
setPurchaseOrderFormErrorMessage('');
|
setPurchaseOrderFormErrorMessage('');
|
||||||
onCancel?.();
|
onCancel?.();
|
||||||
onModalClose?.();
|
onModalClose?.();
|
||||||
|
|||||||
Reference in New Issue
Block a user