Skip to content

Commit

Permalink
Client side routing to improve the navigation times for "View Deposit…
Browse files Browse the repository at this point in the history
… History" (#8375)
  • Loading branch information
naman03malhotra authored Mar 15, 2024
1 parent 9e98720 commit 18227bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-6527-improved-navigation-time
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Used client side navigation to improve the UX for "View Deposit History"
23 changes: 14 additions & 9 deletions client/components/deposits-overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CardHeader,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { getHistory } from '@woocommerce/navigation';

/**
* Internal dependencies.
Expand Down Expand Up @@ -80,6 +81,18 @@ const DepositsOverview: React.FC = () => {
externalAccount.status === 'errored'
) ?? false;

const navigateToDepositsHistory = () => {
recordEvent( 'wcpay_overview_deposits_view_history_click' );

const history = getHistory();
history.push(
getAdminUrl( {
page: 'wc-admin',
path: '/payments/deposits',
} )
);
};

// Show a loading state if the page is still loading.
if ( isLoading ) {
return (
Expand Down Expand Up @@ -189,15 +202,7 @@ const DepositsOverview: React.FC = () => {
{ hasRecentDeposits && (
<Button
variant="secondary"
href={ getAdminUrl( {
page: 'wc-admin',
path: '/payments/deposits',
} ) }
onClick={ () =>
recordEvent(
'wcpay_overview_deposits_view_history_click'
)
}
onClick={ navigateToDepositsHistory }
>
{ __(
'View full deposits history',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ exports[`Deposits Overview information Component Renders 1`] = `
data-wp-c16t="true"
data-wp-component="CardFooter"
>
<a
<button
class="components-button is-secondary"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdeposits"
type="button"
>
View full deposits history
</a>
</button>
<a
class="components-button is-tertiary"
href="admin.php?page=wc-settings&tab=checkout&section=woocommerce_payments#deposit-schedule"
Expand Down

0 comments on commit 18227bd

Please sign in to comment.