Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the filter param in server-side disputes CSV export #9988

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 3 additions & 13 deletions client/data/disputes/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
} 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 @@
( 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 @@
dateBetween.sort( ( a, b ) =>
moment( a ).diff( moment( b ) )
),
search,
filter,
statusIs,
statusIsNot,
orderBy: orderBy || 'created',
Expand Down Expand Up @@ -158,16 +152,12 @@
filter,
status_is: statusIs,
status_is_not: statusIsNot,
search,

Check warning on line 155 in client/data/disputes/hooks.ts

View workflow job for this annotation

GitHub Actions / JS linting

'search' is defined but never used
}: 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'
Expand All @@ -180,7 +170,7 @@
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
Loading