diff --git a/changelog/update-8972-save-payment-activity-preset-session b/changelog/update-8972-save-payment-activity-preset-session new file mode 100644 index 00000000000..869e0b298e5 --- /dev/null +++ b/changelog/update-8972-save-payment-activity-preset-session @@ -0,0 +1,5 @@ +Significance: patch +Type: update +Comment: Part of Payment Activity Card. Persist selected preset date in session. + + diff --git a/client/components/payment-activity/hooks.ts b/client/components/payment-activity/hooks.ts index 2f5d04da975..967ca6cf73a 100644 --- a/client/components/payment-activity/hooks.ts +++ b/client/components/payment-activity/hooks.ts @@ -108,12 +108,14 @@ export const usePaymentActivityDateRangePresets = (): { }, }; + const defaultPreset = + sessionStorage.getItem( 'selectedPresetName' ) ?? 'last_7_days'; const defaultDateRange = { - preset_name: 'last_7_days', - date_start: dateRangePresets.last_7_days.start.format( + preset_name: defaultPreset, + date_start: dateRangePresets[ defaultPreset ].start.format( 'YYYY-MM-DD\\THH:mm:ss' ), - date_end: dateRangePresets.last_7_days.end.format( + date_end: dateRangePresets[ defaultPreset ].end.format( 'YYYY-MM-DD\\THH:mm:ss' ), }; diff --git a/client/components/payment-activity/index.tsx b/client/components/payment-activity/index.tsx index 2e1f8fe2196..4649497cfdf 100644 --- a/client/components/payment-activity/index.tsx +++ b/client/components/payment-activity/index.tsx @@ -130,6 +130,10 @@ const PaymentActivity: React.FC = () => { .clone() .format( 'YYYY-MM-DD\\THH:mm:ss' ); const { key: presetName } = selectedItem; + sessionStorage.setItem( + 'selectedPresetName', + selectedItem.key + ); recordEvent( 'wcpay_overview_payment_activity_period_change', {