mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
refactor(FE): Reset approval notes when opening/closing modals
This commit is contained in:
@@ -100,6 +100,7 @@ const ExpenseRequestContent = ({
|
|||||||
const [isCompleteLoading, setIsCompleteLoading] = useState(false);
|
const [isCompleteLoading, setIsCompleteLoading] = useState(false);
|
||||||
const [isApproveLoading, setIsApproveLoading] = useState(false);
|
const [isApproveLoading, setIsApproveLoading] = useState(false);
|
||||||
const [isRejectLoading, setIsRejectLoading] = useState(false);
|
const [isRejectLoading, setIsRejectLoading] = useState(false);
|
||||||
|
const [, setApprovalNotes] = useState('');
|
||||||
|
|
||||||
const formik = useFormik<UploadRequestDocumentsFormValues>({
|
const formik = useFormik<UploadRequestDocumentsFormValues>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
@@ -130,10 +131,12 @@ const ExpenseRequestContent = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const approveClickHandler = () => {
|
const approveClickHandler = () => {
|
||||||
|
setApprovalNotes('');
|
||||||
approveModal.openModal();
|
approveModal.openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
const rejectClickHandler = () => {
|
const rejectClickHandler = () => {
|
||||||
|
setApprovalNotes('');
|
||||||
rejectModal.openModal();
|
rejectModal.openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,6 +203,7 @@ const ExpenseRequestContent = ({
|
|||||||
approveModal.closeModal();
|
approveModal.closeModal();
|
||||||
|
|
||||||
toast.success(approveResponse?.message);
|
toast.success(approveResponse?.message);
|
||||||
|
setApprovalNotes('');
|
||||||
router.push('/expense');
|
router.push('/expense');
|
||||||
} else {
|
} else {
|
||||||
approveModal.closeModal();
|
approveModal.closeModal();
|
||||||
@@ -234,6 +238,7 @@ const ExpenseRequestContent = ({
|
|||||||
rejectModal.closeModal();
|
rejectModal.closeModal();
|
||||||
|
|
||||||
toast.success(rejectResponse.message);
|
toast.success(rejectResponse.message);
|
||||||
|
setApprovalNotes('');
|
||||||
router.push('/expense');
|
router.push('/expense');
|
||||||
} else {
|
} else {
|
||||||
rejectModal.closeModal();
|
rejectModal.closeModal();
|
||||||
@@ -710,6 +715,10 @@ const ExpenseRequestContent = ({
|
|||||||
text='Apakah anda yakin ingin approve data biaya operasional ini?'
|
text='Apakah anda yakin ingin approve data biaya operasional ini?'
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
approveModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
primaryButton={{
|
primaryButton={{
|
||||||
text: 'Ya',
|
text: 'Ya',
|
||||||
@@ -725,6 +734,10 @@ const ExpenseRequestContent = ({
|
|||||||
text='Apakah anda yakin ingin reject data biaya operasional ini?'
|
text='Apakah anda yakin ingin reject data biaya operasional ini?'
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
rejectModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
primaryButton={{
|
primaryButton={{
|
||||||
text: 'Ya',
|
text: 'Ya',
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ const ExpensesTable = () => {
|
|||||||
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
||||||
const [isApproveLoading, setIsApproveLoading] = useState(false);
|
const [isApproveLoading, setIsApproveLoading] = useState(false);
|
||||||
const [isRejectLoading, setIsRejectLoading] = useState(false);
|
const [isRejectLoading, setIsRejectLoading] = useState(false);
|
||||||
|
const [, setApprovalNotes] = useState('');
|
||||||
|
|
||||||
const [sorting, setSorting] = useState<SortingState>([]);
|
const [sorting, setSorting] = useState<SortingState>([]);
|
||||||
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
|
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
|
||||||
@@ -342,6 +343,7 @@ const ExpensesTable = () => {
|
|||||||
[String(props.row.original.id)]: true,
|
[String(props.row.original.id)]: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setApprovalNotes('');
|
||||||
approveModal.openModal();
|
approveModal.openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -353,6 +355,7 @@ const ExpensesTable = () => {
|
|||||||
[String(props.row.original.id)]: true,
|
[String(props.row.original.id)]: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setApprovalNotes('');
|
||||||
rejectModal.openModal();
|
rejectModal.openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -412,10 +415,12 @@ const ExpensesTable = () => {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
const bulkApproveClickHandler = () => {
|
const bulkApproveClickHandler = () => {
|
||||||
|
setApprovalNotes('');
|
||||||
approveModal.openModal();
|
approveModal.openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
const bulkRejectClickHandler = () => {
|
const bulkRejectClickHandler = () => {
|
||||||
|
setApprovalNotes('');
|
||||||
rejectModal.openModal();
|
rejectModal.openModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -468,6 +473,7 @@ const ExpensesTable = () => {
|
|||||||
`Berhasil approve ${selectedRowIds.length} data biaya operasional!`
|
`Berhasil approve ${selectedRowIds.length} data biaya operasional!`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setApprovalNotes('');
|
||||||
setRowSelection({});
|
setRowSelection({});
|
||||||
} else {
|
} else {
|
||||||
approveModal.closeModal();
|
approveModal.closeModal();
|
||||||
@@ -509,6 +515,7 @@ const ExpensesTable = () => {
|
|||||||
toast.success(
|
toast.success(
|
||||||
`Berhasil reject ${selectedRowIds.length} data biaya operasional!`
|
`Berhasil reject ${selectedRowIds.length} data biaya operasional!`
|
||||||
);
|
);
|
||||||
|
setApprovalNotes('');
|
||||||
setRowSelection({});
|
setRowSelection({});
|
||||||
} else {
|
} else {
|
||||||
rejectModal.closeModal();
|
rejectModal.closeModal();
|
||||||
@@ -787,6 +794,10 @@ const ExpensesTable = () => {
|
|||||||
text='Apakah anda yakin ingin approve data biaya operasional ini?'
|
text='Apakah anda yakin ingin approve data biaya operasional ini?'
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
approveModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
primaryButton={{
|
primaryButton={{
|
||||||
text: 'Ya',
|
text: 'Ya',
|
||||||
@@ -802,6 +813,10 @@ const ExpensesTable = () => {
|
|||||||
text='Apakah anda yakin ingin reject data biaya operasional ini?'
|
text='Apakah anda yakin ingin reject data biaya operasional ini?'
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
rejectModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
primaryButton={{
|
primaryButton={{
|
||||||
text: 'Ya',
|
text: 'Ya',
|
||||||
|
|||||||
@@ -3154,7 +3154,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
text='Apakah anda yakin ingin menyetujui data Recording ini?'
|
text='Apakah anda yakin ingin menyetujui data Recording ini?'
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
onClick: () => setApprovalNotes(''),
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
approveModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
primaryButton={{
|
primaryButton={{
|
||||||
text: 'Ya',
|
text: 'Ya',
|
||||||
@@ -3176,7 +3179,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
text='Apakah anda yakin ingin menolak data Recording ini?'
|
text='Apakah anda yakin ingin menolak data Recording ini?'
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Tidak',
|
text: 'Tidak',
|
||||||
onClick: () => setApprovalNotes(''),
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
rejectModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
primaryButton={{
|
primaryButton={{
|
||||||
text: 'Ya',
|
text: 'Ya',
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ const PurchaseOrderDetail = ({
|
|||||||
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
|
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
|
||||||
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
||||||
const [selectedItem, setSelectedItem] = useState<PurchaseItem | null>(null);
|
const [selectedItem, setSelectedItem] = useState<PurchaseItem | null>(null);
|
||||||
|
const [, setApprovalNotes] = useState('');
|
||||||
|
|
||||||
const selectedRowIds = Object.keys(rowSelection).map((item) =>
|
const selectedRowIds = Object.keys(rowSelection).map((item) =>
|
||||||
parseInt(item)
|
parseInt(item)
|
||||||
@@ -207,12 +208,15 @@ const PurchaseOrderDetail = ({
|
|||||||
|
|
||||||
switch (approvalStep) {
|
switch (approvalStep) {
|
||||||
case 1:
|
case 1:
|
||||||
|
setApprovalNotes('');
|
||||||
staffApprovalModal.openModal();
|
staffApprovalModal.openModal();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
setApprovalNotes('');
|
||||||
confirmationModalWithNotes.openModal();
|
confirmationModalWithNotes.openModal();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
setApprovalNotes('');
|
||||||
acceptApprovalModal.openModal();
|
acceptApprovalModal.openModal();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -225,12 +229,15 @@ const PurchaseOrderDetail = ({
|
|||||||
|
|
||||||
switch (approvalStep) {
|
switch (approvalStep) {
|
||||||
case 1:
|
case 1:
|
||||||
|
setApprovalNotes('');
|
||||||
staffRejectionModal.openModal();
|
staffRejectionModal.openModal();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
setApprovalNotes('');
|
||||||
managerRejectionModal.openModal();
|
managerRejectionModal.openModal();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
setApprovalNotes('');
|
||||||
acceptRejectionModal.openModal();
|
acceptRejectionModal.openModal();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -978,11 +985,16 @@ const PurchaseOrderDetail = ({
|
|||||||
await createManagerApprovalHandler(payload);
|
await createManagerApprovalHandler(payload);
|
||||||
await refreshApprovals();
|
await refreshApprovals();
|
||||||
await refetchData?.();
|
await refetchData?.();
|
||||||
|
setApprovalNotes('');
|
||||||
confirmationModalWithNotes.closeModal();
|
confirmationModalWithNotes.closeModal();
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Batal',
|
text: 'Batal',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
confirmationModalWithNotes.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -1079,11 +1091,16 @@ const PurchaseOrderDetail = ({
|
|||||||
|
|
||||||
await createStaffApprovalHandler(payload);
|
await createStaffApprovalHandler(payload);
|
||||||
await refetchData?.();
|
await refetchData?.();
|
||||||
|
setApprovalNotes('');
|
||||||
staffRejectionModal.closeModal();
|
staffRejectionModal.closeModal();
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Batal',
|
text: 'Batal',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
staffRejectionModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -1106,11 +1123,16 @@ const PurchaseOrderDetail = ({
|
|||||||
|
|
||||||
await createAcceptApprovalHandler(payload);
|
await createAcceptApprovalHandler(payload);
|
||||||
await refetchData?.();
|
await refetchData?.();
|
||||||
|
setApprovalNotes('');
|
||||||
acceptRejectionModal.closeModal();
|
acceptRejectionModal.closeModal();
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Batal',
|
text: 'Batal',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
acceptRejectionModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -1133,11 +1155,16 @@ const PurchaseOrderDetail = ({
|
|||||||
|
|
||||||
await createManagerApprovalHandler(payload);
|
await createManagerApprovalHandler(payload);
|
||||||
await refetchData?.();
|
await refetchData?.();
|
||||||
|
setApprovalNotes('');
|
||||||
managerRejectionModal.closeModal();
|
managerRejectionModal.closeModal();
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
secondaryButton={{
|
secondaryButton={{
|
||||||
text: 'Batal',
|
text: 'Batal',
|
||||||
|
onClick: () => {
|
||||||
|
setApprovalNotes('');
|
||||||
|
managerRejectionModal.closeModal();
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user