Skip to content

Commit

Permalink
Use the filter param in server-side disputes CSV export (#9988)
Browse files Browse the repository at this point in the history
Co-authored-by: Jessy <jessy.pappachan@automattic.com>
Co-authored-by: Nagesh Pai <nagesh.pai@automattic.com>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent 5005b6b commit a648153
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-9987-filter-csv-disputes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix filtering in async Disputes CSV export
15 changes: 2 additions & 13 deletions client/data/disputes/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -98,11 +97,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'
Expand All @@ -119,7 +113,7 @@ export const useDisputes = ( {
dateBetween.sort( ( a, b ) =>
moment( a ).diff( moment( b ) )
),
search,
filter,
statusIs,
statusIsNot,
orderBy: orderBy || 'created',
Expand Down Expand Up @@ -163,11 +157,6 @@ export const useDisputesSummary = ( {
( select ) => {
const { getDisputesSummary, isResolving } = select( STORE_NAME );

const search =
filter === 'awaiting_response'
? disputeAwaitingResponseStatuses
: undefined;

const query = {
paged: Number.isNaN( parseInt( paged ?? '', 10 ) )
? '1'
Expand All @@ -180,7 +169,7 @@ export const useDisputesSummary = ( {
dateBefore,
dateAfter,
dateBetween,
search,
filter,
statusIs,
statusIsNot,
};
Expand Down
7 changes: 5 additions & 2 deletions client/data/disputes/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
updateDisputesSummary,
updateErrorForDispute,
} from './actions';
import { disputeAwaitingResponseStatuses } from 'wcpay/disputes/filters/config';

const formatQueryFilters = ( query ) => ( {
user_email: query.userEmail,
Expand All @@ -31,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,
Expand All @@ -42,7 +46,6 @@ export function getDisputesCSV( query ) {
`${ NAMESPACE }/disputes/download`,
formatQueryFilters( query )
);

return path;
}

Expand Down
2 changes: 2 additions & 0 deletions client/disputes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -407,6 +408,7 @@ export const DisputesList = (): JSX.Element => {
dateBefore,
dateBetween,
match,
filter,
statusIs,
statusIsNot,
} ),
Expand Down

0 comments on commit a648153

Please sign in to comment.