From b6e8874d5fbc3a2f0c80d6940e0ccd17e417b607 Mon Sep 17 00:00:00 2001
From: Nagesh Pai <4162931+nagpai@users.noreply.github.com>
Date: Thu, 2 May 2024 14:27:49 +0530
Subject: [PATCH] Reporting: Fix the `View report` link URL on Total payment
volume tile, within Payment activity widget (#8726)
Co-authored-by: Nagesh Pai
Co-authored-by: Jessy Pappachan <32092402+jessy-p@users.noreply.github.com>
---
changelog/fix-8706-tpv-view-report-link | 5 +++
.../payment-activity-data.tsx | 33 +++++++++++++++++--
.../test/__snapshots__/index.test.tsx.snap | 6 ++--
client/transactions/list/style.scss | 7 ++--
4 files changed, 43 insertions(+), 8 deletions(-)
create mode 100644 changelog/fix-8706-tpv-view-report-link
diff --git a/changelog/fix-8706-tpv-view-report-link b/changelog/fix-8706-tpv-view-report-link
new file mode 100644
index 00000000000..296aa87cf5c
--- /dev/null
+++ b/changelog/fix-8706-tpv-view-report-link
@@ -0,0 +1,5 @@
+Significance: patch
+Type: fix
+Comment: Comment: Fix the `View report` link on Total payment volume tile on the Payment activity widget. Changes behind feature flag, and part of larger change that adds the Payment activity widget.
+
+
diff --git a/client/components/payment-activity/payment-activity-data.tsx b/client/components/payment-activity/payment-activity-data.tsx
index d9944671434..788f678dce0 100644
--- a/client/components/payment-activity/payment-activity-data.tsx
+++ b/client/components/payment-activity/payment-activity-data.tsx
@@ -23,14 +23,38 @@ import './style.scss';
*/
const getDateRange = (): DateRange => {
return {
- // Subtract 7 days from the current date.
+ // Subtract 6 days from the current date. 7 days including the current day.
date_start: moment()
- .subtract( 7, 'd' )
+ .subtract( 6, 'd' )
.format( 'YYYY-MM-DD\\THH:mm:ss' ),
date_end: moment().format( 'YYYY-MM-DD\\THH:mm:ss' ),
};
};
+const searchTermsForViewReportLink = {
+ totalPaymentVolume: [
+ 'charge',
+ 'payment',
+ 'payment_failure_refund',
+ 'payment_refund',
+ 'refund',
+ 'refund_failure',
+ 'dispute',
+ 'dispute_reversal',
+ 'card_reader_fee',
+ ],
+};
+
+const getSearchParams = ( searchTerms: string[] ) => {
+ return searchTerms.reduce(
+ ( acc, term, index ) => ( {
+ ...acc,
+ [ `search[${ index }]` ]: term,
+ } ),
+ {}
+ );
+};
+
const PaymentActivityData: React.FC = () => {
const { paymentActivityData, isLoading } = usePaymentActivityData(
getDateRange()
@@ -86,13 +110,16 @@ const PaymentActivityData: React.FC = () => {
reportLink={ getAdminUrl( {
page: 'wc-admin',
path: '/payments/transactions',
+ filter: 'advanced',
'date_between[0]': moment(
getDateRange().date_start
).format( 'YYYY-MM-DD' ),
'date_between[1]': moment( getDateRange().date_end ).format(
'YYYY-MM-DD'
),
- filter: 'advanced',
+ ...getSearchParams(
+ searchTermsForViewReportLink.totalPaymentVolume
+ ),
} ) }
tracksSource="total_payment_volume"
isLoading={ isLoading }
diff --git a/client/components/payment-activity/test/__snapshots__/index.test.tsx.snap b/client/components/payment-activity/test/__snapshots__/index.test.tsx.snap
index 0b4f5e397a8..a45a33735e0 100644
--- a/client/components/payment-activity/test/__snapshots__/index.test.tsx.snap
+++ b/client/components/payment-activity/test/__snapshots__/index.test.tsx.snap
@@ -76,7 +76,7 @@ exports[`PaymentActivity component should render 1`] = `
View report
@@ -165,7 +165,7 @@ exports[`PaymentActivity component should render 1`] = `
View report
@@ -194,7 +194,7 @@ exports[`PaymentActivity component should render 1`] = `
View report
diff --git a/client/transactions/list/style.scss b/client/transactions/list/style.scss
index e33b7755e91..90288f81f17 100644
--- a/client/transactions/list/style.scss
+++ b/client/transactions/list/style.scss
@@ -121,8 +121,11 @@ $gap-small: 12px;
.woocommerce-search {
margin: 0 $gap;
- .woocommerce-select-control__control {
- height: 38px;
+ .components-base-control {
+ &.woocommerce-select-control__control {
+ min-height: 38px;
+ height: auto;
+ }
}
}