Skip to content

Commit 629f7b4

Browse files
yashwinclaude
andcommitted
A4A MSD: point WooPayments license queries at the shared helper
Now that the commissions dashboard lives in the MSD dashboard, switch the remaining attached-WooPayments-licenses call sites — the dashboard data hook, the route-loader prefetch, and the classic landing page — to wooPaymentsLicensesQuery and WOOPAYMENTS_PLUGIN, so their cache keys can never drift from the overview store count. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 8d451d0 commit 629f7b4

3 files changed

Lines changed: 10 additions & 40 deletions

File tree

client/a8c-for-agencies/sections/woopayments/primary/woopayment-landing/index.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
JetpackLicenseFilter,
3-
JetpackLicenseSortField,
4-
JetpackLicenseSortDirection,
5-
} from '@automattic/api-core';
6-
import { jetpackAgencyLicensesQuery } from '@automattic/api-queries';
1+
import { wooPaymentsLicensesQuery } from '@automattic/api-queries';
72
import page from '@automattic/calypso-router';
83
import { useQuery } from '@tanstack/react-query';
94
import { useTranslate } from 'i18n-calypso';
@@ -23,12 +18,7 @@ const WooPaymentsLanding = () => {
2318
const agencyId = useSelector( getActiveAgencyId );
2419

2520
const { data: licenses, isFetched } = useQuery( {
26-
...jetpackAgencyLicensesQuery( agencyId ?? 0, {
27-
filter: JetpackLicenseFilter.Attached,
28-
search: 'woopayments',
29-
sortField: JetpackLicenseSortField.IssuedAt,
30-
sortDirection: JetpackLicenseSortDirection.Descending,
31-
} ),
21+
...wooPaymentsLicensesQuery( agencyId ?? 0 ),
3222
enabled: !! agencyId,
3323
refetchOnWindowFocus: false,
3424
} );

client/dashboard/agency/earn/woopayments/use-woopayments-dashboard-data.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import {
2-
JetpackLicenseFilter,
3-
JetpackLicenseSortField,
4-
JetpackLicenseSortDirection,
5-
} from '@automattic/api-core';
61
import {
72
agencySitesWithPluginsQuery,
83
agencyWooPaymentsDataQuery,
9-
jetpackAgencyLicensesQuery,
104
jetpackTestConnectionQuery,
5+
wooPaymentsLicensesQuery,
6+
WOOPAYMENTS_PLUGIN,
117
} from '@automattic/api-queries';
128
import { useQueries, useQuery } from '@tanstack/react-query';
139
import { useMemo } from 'react';
@@ -54,12 +50,7 @@ export interface WooPaymentsDashboardData {
5450
*/
5551
export default function useWooPaymentsDashboardData( agencyId: number ): WooPaymentsDashboardData {
5652
const { data: licenseSites, isLoading: isLoadingLicensesWithWooPayments } = useQuery( {
57-
...jetpackAgencyLicensesQuery( agencyId, {
58-
filter: JetpackLicenseFilter.Attached,
59-
search: 'woopayments',
60-
sortField: JetpackLicenseSortField.IssuedAt,
61-
sortDirection: JetpackLicenseSortDirection.Descending,
62-
} ),
53+
...wooPaymentsLicensesQuery( agencyId ),
6354
enabled: !! agencyId,
6455
refetchOnWindowFocus: false,
6556
select: ( licenses ) =>
@@ -71,7 +62,7 @@ export default function useWooPaymentsDashboardData( agencyId: number ): WooPaym
7162
} );
7263

7364
const { isLoading: isLoadingSitesWithPlugins, data: sitesWithPlugins } = useQuery( {
74-
...agencySitesWithPluginsQuery( agencyId, [ 'woocommerce-payments/woocommerce-payments' ] ),
65+
...agencySitesWithPluginsQuery( agencyId, [ WOOPAYMENTS_PLUGIN ] ),
7566
enabled: !! agencyId,
7667
refetchOnWindowFocus: false,
7768
} );

client/dashboard/app/router/agency.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import {
2-
JetpackLicenseFilter,
3-
JetpackLicenseSortField,
4-
JetpackLicenseSortDirection,
5-
} from '@automattic/api-core';
61
import {
72
activeAgencyQuery,
83
agencyProductsQuery,
@@ -11,7 +6,6 @@ import {
116
agencySiteQuery,
127
agencySitesWithPluginsQuery,
138
agencyWooPaymentsDataQuery,
14-
jetpackAgencyLicensesQuery,
159
mcpSettingsQuery,
1610
queryClient,
1711
rawUserPreferencesQuery,
@@ -22,6 +16,8 @@ import {
2216
referralsQuery,
2317
referralCommissionPayoutQuery,
2418
tipaltiPayeeQuery,
19+
wooPaymentsLicensesQuery,
20+
WOOPAYMENTS_PLUGIN,
2521
} from '@automattic/api-queries';
2622
import { createRoute, createLazyRoute, notFound, Outlet } from '@tanstack/react-router';
2723
import { __ } from '@wordpress/i18n';
@@ -307,16 +303,9 @@ export const earnWooPaymentsRoute = createRoute( {
307303
}
308304
const [ sitesWithPlugins, licenses ] = await Promise.all( [
309305
queryClient.ensureQueryData(
310-
agencySitesWithPluginsQuery( agency.id, [ 'woocommerce-payments/woocommerce-payments' ] )
311-
),
312-
queryClient.ensureQueryData(
313-
jetpackAgencyLicensesQuery( agency.id, {
314-
filter: JetpackLicenseFilter.Attached,
315-
search: 'woopayments',
316-
sortField: JetpackLicenseSortField.IssuedAt,
317-
sortDirection: JetpackLicenseSortDirection.Descending,
318-
} )
306+
agencySitesWithPluginsQuery( agency.id, [ WOOPAYMENTS_PLUGIN ] )
319307
),
308+
queryClient.ensureQueryData( wooPaymentsLicensesQuery( agency.id ) ),
320309
] );
321310
if ( sitesWithPlugins.length > 0 || licenses.length > 0 ) {
322311
await Promise.all( [

0 commit comments

Comments
 (0)