refactor(FE): Refactor CustomerPaymentTab to use filterParams instead of

formik values
This commit is contained in:
rstubryan
2026-03-05 11:01:52 +07:00
parent b5fc1d4310
commit 267ef9d812
@@ -119,7 +119,6 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
}, },
}); });
// Set the ref callback after formik is initialized
handleFilterModalOpenRef.current = () => { handleFilterModalOpenRef.current = () => {
filterModal.openModal(); filterModal.openModal();
formik.validateForm(); formik.validateForm();
@@ -360,15 +359,12 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
(state) => state.clearTabActions (state) => state.clearTabActions
); );
const formikValuesRef = useRef(formik.values);
formikValuesRef.current = formik.values;
useEffect(() => { useEffect(() => {
setTabActions( setTabActions(
tabId, tabId,
<div className='flex flex-row gap-3'> <div className='flex flex-row gap-3'>
<ButtonFilter <ButtonFilter
values={formikValuesRef.current} values={filterParams}
fieldGroups={[['start_date', 'end_date']]} fieldGroups={[['start_date', 'end_date']]}
onClick={() => handleFilterModalOpenRef.current()} onClick={() => handleFilterModalOpenRef.current()}
variant='outline' variant='outline'
@@ -449,7 +445,7 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
handleExportPdf, handleExportPdf,
isExcelExportLoading, isExcelExportLoading,
isPdfExportLoading, isPdfExportLoading,
formik.values, filterParams,
]); ]);
const TabActionsElement = useMemo(() => <TabActions />, [TabActions]); const TabActionsElement = useMemo(() => <TabActions />, [TabActions]);