Skip to content

Commit

Permalink
Stats: Fix purchase page for site-less flow (#95646)
Browse files Browse the repository at this point in the history
* Revert "Use StatsPageLoader to wrap purchase page"

This reverts commit 7a98290.

* Update annotations for purchase page controller
  • Loading branch information
dognose24 authored Oct 24, 2024
1 parent 0b516ce commit c0da961
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 7 additions & 8 deletions client/my-sites/stats/pages/purchase/controller.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import AsyncLoad from 'calypso/components/async-load';
import StatsPageLoader from '../../stats-page-loader';
import PageLoading from '../shared/page-loading';
import type { Context } from '@automattic/calypso-router';

function purchase( context: Context, next: () => void ) {
context.primary = (
<StatsPageLoader>
<AsyncLoad
require="calypso/my-sites/stats/pages/purchase"
placeholder={ PageLoading }
query={ context.query }
/>
</StatsPageLoader>
// DO NOT WRAP WITH <StatsPageLoader />
// Or the site-less purchase flow will not work because there is no permission to access Stats.
<AsyncLoad
require="calypso/my-sites/stats/pages/purchase"
placeholder={ PageLoading }
query={ context.query }
/>
);
next();
}
Expand Down
4 changes: 4 additions & 0 deletions client/my-sites/stats/pages/purchase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useEffect, useMemo } from 'react';
import StatsNavigation from 'calypso/blocks/stats-navigation';
import DocumentHead from 'calypso/components/data/document-head';
import QueryProductsList from 'calypso/components/data/query-products-list';
import QuerySitePurchases from 'calypso/components/data/query-site-purchases';
import InlineSupportLink from 'calypso/components/inline-support-link';
import JetpackColophon from 'calypso/components/jetpack-colophon';
import Main from 'calypso/components/main';
Expand Down Expand Up @@ -198,6 +199,9 @@ const StatsPurchasePage = ( {
/>
</>
) }

{ /* Only query site purchases on Calypso via existing data component */ }
<QuerySitePurchases siteId={ siteId } />
<QueryProductsList type="jetpack" />
{ isLoading && (
<div className="stats-purchase-page__loader">
Expand Down

0 comments on commit c0da961

Please sign in to comment.