From 09d7c8d3b798c71c3d4c5221d4a5dc734c4729ed Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 08:04:00 +0530 Subject: [PATCH 1/6] Fix awaiting response filtering in disputes CSV export --- client/data/disputes/resolvers.js | 12 ++++++++++-- client/disputes/index.tsx | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/data/disputes/resolvers.js b/client/data/disputes/resolvers.js index bf45770537c..e68c2908bae 100644 --- a/client/data/disputes/resolvers.js +++ b/client/data/disputes/resolvers.js @@ -20,6 +20,7 @@ import { updateDisputesSummary, updateErrorForDispute, } from './actions'; +import { disputeAwaitingResponseStatuses } from 'wcpay/disputes/filters/config'; const formatQueryFilters = ( query ) => ( { user_email: query.userEmail, @@ -38,11 +39,18 @@ const formatQueryFilters = ( query ) => ( { } ); export function getDisputesCSV( query ) { + const queryWithSearch = { + ...query, + search: + query.filter === 'awaiting_response' + ? disputeAwaitingResponseStatuses + : query.search, + }; + const path = addQueryArgs( `${ NAMESPACE }/disputes/download`, - formatQueryFilters( query ) + formatQueryFilters( queryWithSearch ) ); - return path; } diff --git a/client/disputes/index.tsx b/client/disputes/index.tsx index 060afccce35..cdb85131f5d 100644 --- a/client/disputes/index.tsx +++ b/client/disputes/index.tsx @@ -372,6 +372,7 @@ export const DisputesList = (): JSX.Element => { date_after: dateAfter, date_between: dateBetween, match, + filter, status_is: statusIs, status_is_not: statusIsNot, } = getQuery(); @@ -407,6 +408,7 @@ export const DisputesList = (): JSX.Element => { dateBefore, dateBetween, match, + filter, statusIs, statusIsNot, } ), From a89f43447c41e2ac74c018357019523f1a024c36 Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 08:34:57 +0530 Subject: [PATCH 2/6] Add changelog --- changelog/fix-9987-filter-csv-disputes | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-9987-filter-csv-disputes diff --git a/changelog/fix-9987-filter-csv-disputes b/changelog/fix-9987-filter-csv-disputes new file mode 100644 index 00000000000..11582015d29 --- /dev/null +++ b/changelog/fix-9987-filter-csv-disputes @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix filtering on server-side Disputes filtering From dc09a57ec64d26e871ae3cf0beda6c3ef12dd85c Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 10:40:00 +0530 Subject: [PATCH 3/6] Move 'awaiting_response' filtering to formatQueryFilters for all dispute endpoints --- client/data/disputes/hooks.ts | 15 +++------------ client/data/disputes/resolvers.js | 5 ++++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/client/data/disputes/hooks.ts b/client/data/disputes/hooks.ts index b8a95b1e5e6..1e0e4409ec9 100644 --- a/client/data/disputes/hooks.ts +++ b/client/data/disputes/hooks.ts @@ -98,11 +98,6 @@ export const useDisputes = ( { ( select ) => { const { getDisputes, isResolving } = select( STORE_NAME ); - const search = - filter === 'awaiting_response' - ? disputeAwaitingResponseStatuses - : undefined; - const query = { paged: Number.isNaN( parseInt( paged ?? '', 10 ) ) ? '1' @@ -119,7 +114,7 @@ export const useDisputes = ( { dateBetween.sort( ( a, b ) => moment( a ).diff( moment( b ) ) ), - search, + filter, statusIs, statusIsNot, orderBy: orderBy || 'created', @@ -158,16 +153,12 @@ export const useDisputesSummary = ( { filter, status_is: statusIs, status_is_not: statusIsNot, + search, }: Query ): DisputesSummary => useSelect( ( select ) => { const { getDisputesSummary, isResolving } = select( STORE_NAME ); - const search = - filter === 'awaiting_response' - ? disputeAwaitingResponseStatuses - : undefined; - const query = { paged: Number.isNaN( parseInt( paged ?? '', 10 ) ) ? '1' @@ -180,7 +171,7 @@ export const useDisputesSummary = ( { dateBefore, dateAfter, dateBetween, - search, + filter, statusIs, statusIsNot, }; diff --git a/client/data/disputes/resolvers.js b/client/data/disputes/resolvers.js index e68c2908bae..455383a5aa8 100644 --- a/client/data/disputes/resolvers.js +++ b/client/data/disputes/resolvers.js @@ -32,7 +32,10 @@ const formatQueryFilters = ( query ) => ( { formatDateValue( query.dateBetween[ 0 ] ), formatDateValue( query.dateBetween[ 1 ], true ), ], - search: query.search, + search: + query.filter === 'awaiting_response' + ? disputeAwaitingResponseStatuses + : query.search, status_is: query.statusIs, status_is_not: query.statusIsNot, locale: query.locale, From 0a6185a2c3db028011eda6ed671bc26a806e0836 Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 10:53:46 +0530 Subject: [PATCH 4/6] removed unnecessary import --- client/data/disputes/hooks.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/client/data/disputes/hooks.ts b/client/data/disputes/hooks.ts index 1e0e4409ec9..1668529f5a8 100644 --- a/client/data/disputes/hooks.ts +++ b/client/data/disputes/hooks.ts @@ -17,7 +17,6 @@ import type { } from 'wcpay/types/disputes'; import type { ApiError } from 'wcpay/types/errors'; import { STORE_NAME } from '../constants'; -import { disputeAwaitingResponseStatuses } from 'wcpay/disputes/filters/config'; /** * Returns the dispute object, error object, and loading state. From 0239dcf5b892dc3985fc778a3f4c8ba787f18277 Mon Sep 17 00:00:00 2001 From: Jessy Date: Wed, 18 Dec 2024 11:10:54 +0530 Subject: [PATCH 5/6] Removed code from getDisputesCSV --- client/data/disputes/resolvers.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/client/data/disputes/resolvers.js b/client/data/disputes/resolvers.js index 455383a5aa8..ce748a46562 100644 --- a/client/data/disputes/resolvers.js +++ b/client/data/disputes/resolvers.js @@ -42,17 +42,9 @@ const formatQueryFilters = ( query ) => ( { } ); export function getDisputesCSV( query ) { - const queryWithSearch = { - ...query, - search: - query.filter === 'awaiting_response' - ? disputeAwaitingResponseStatuses - : query.search, - }; - const path = addQueryArgs( `${ NAMESPACE }/disputes/download`, - formatQueryFilters( queryWithSearch ) + formatQueryFilters( query ) ); return path; } From cc5bf3b03dc2529234644cfee06ad7a202d9d38c Mon Sep 17 00:00:00 2001 From: Jessy Pappachan <32092402+jessy-p@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:14:03 +0530 Subject: [PATCH 6/6] update the changelog --- changelog/fix-9987-filter-csv-disputes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/fix-9987-filter-csv-disputes b/changelog/fix-9987-filter-csv-disputes index 11582015d29..e4a87b24b1b 100644 --- a/changelog/fix-9987-filter-csv-disputes +++ b/changelog/fix-9987-filter-csv-disputes @@ -1,4 +1,4 @@ Significance: patch Type: fix -Fix filtering on server-side Disputes filtering +Fix filtering in async Disputes CSV export