Skip to content

Commit

Permalink
Save selected date preset into session (#8983)
Browse files Browse the repository at this point in the history
Co-authored-by: Jessy <[email protected]>
Co-authored-by: Rua Haszard <[email protected]>
  • Loading branch information
3 people authored Jun 21, 2024
1 parent 544f297 commit aac2f27
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/update-8972-save-payment-activity-preset-session
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: update
Comment: Part of Payment Activity Card. Persist selected preset date in session.


8 changes: 5 additions & 3 deletions client/components/payment-activity/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
),
};
Expand Down
4 changes: 4 additions & 0 deletions client/components/payment-activity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
{
Expand Down

0 comments on commit aac2f27

Please sign in to comment.