From 48dd41df30dfdbbb4bb0800f9a631252ae9005ad Mon Sep 17 00:00:00 2001 From: Henrique Moreira <98126579+henriquemoreiraa@users.noreply.github.com> Date: Mon, 14 Nov 2022 17:10:13 -0300 Subject: [PATCH] fix: payments filter not working (#937) --- .../CustomTableFilter/CustomTableFilter.js | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/components/common/CustomTableFilter/CustomTableFilter.js b/src/components/common/CustomTableFilter/CustomTableFilter.js index f414c9416..dccb9eb07 100644 --- a/src/components/common/CustomTableFilter/CustomTableFilter.js +++ b/src/components/common/CustomTableFilter/CustomTableFilter.js @@ -35,7 +35,7 @@ const PAYMENT_STATUS = ['calculated', 'cancelled', 'paid', 'all']; function CustomTableFilter(props) { // console.warn('orgList', orgList); const initialFilter = { - organization_id: '', + // organization_id: '', grower: '', payment_status: 'all', earnings_status: 'all', @@ -75,9 +75,11 @@ function CustomTableFilter(props) { e.preventDefault(); const filtersToSubmit = { ...filter, - ...localFilter, - grower: localFilter.grower.trim(), - phone: localFilter.phone.trim(), + grower: localFilter.grower ? localFilter.grower.trim() : undefined, + phone: localFilter.phone ? localFilter.phone.trim() : undefined, + payment_status: disablePaymentStatus + ? undefined + : localFilter.payment_status, }; if (filtersToSubmit.organization_id === ALL_ORGANIZATIONS) { @@ -100,7 +102,12 @@ function CustomTableFilter(props) { const handleOnFilterFormReset = (e) => { e.preventDefault(); - setFilter(initialFilter); + disablePaymentStatus + ? setFilter({ + payment_status: undefined, + grower: undefined, + }) + : setFilter({ ...initialFilter, grower: '' }); setLocalFilter(initialFilter); setIsFilterOpen(false); }; @@ -170,23 +177,25 @@ function CustomTableFilter(props) { )} - - - + {!disablePaymentStatus && ( + + + + )}