Skip to content

Commit 05cee69

Browse files
Merge pull request #18861 from mozilla/FXA-11389
fix(payments-next): Update layout/page metadata
2 parents 09300fb + 7b8889c commit 05cee69

15 files changed

Lines changed: 306 additions & 58 deletions

File tree

apps/payments/next/app/[locale]/[offeringId]/[interval]/checkout/[cartId]/error/page.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,32 @@ import {
2121
import { config } from 'apps/payments/next/config';
2222
import type { Metadata } from 'next';
2323
import { CartErrorReasonId } from '@fxa/shared/db/mysql/account';
24+
import { buildPageMetadata } from '@fxa/payments/ui';
2425

2526
// forces dynamic rendering
2627
// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
2728
export const dynamic = 'force-dynamic';
2829

29-
export const metadata: Metadata = {
30-
title: 'Error',
31-
description:
32-
'There was an error processing your subscription. If this problem persists, please contact support.',
33-
};
30+
export async function generateMetadata(
31+
{
32+
params,
33+
searchParams,
34+
}: {
35+
params: CheckoutParams;
36+
searchParams: Record<string, string> | undefined;
37+
},
38+
): Promise<Metadata> {
39+
return buildPageMetadata({
40+
params,
41+
titlePrefix: 'Error',
42+
description: 'There was an error processing your subscription. If this problem persists, please contact support.',
43+
page: 'error',
44+
pageType: 'checkout',
45+
acceptLanguage: headers().get('accept-language'),
46+
baseUrl: config.paymentsNextHostedUrl,
47+
searchParams
48+
});
49+
}
3450

3551
export default async function CheckoutError({
3652
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/checkout/[cartId]/needs_input/page.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,34 @@ import {
77
LoadingSpinner,
88
StripeWrapper,
99
PaymentInputHandler,
10+
buildPageMetadata,
1011
} from '@fxa/payments/ui';
1112
import { getApp, SupportedPages } from '@fxa/payments/ui/server';
1213
import { headers } from 'next/headers';
1314
import { getCartOrRedirectAction } from '@fxa/payments/ui/actions';
1415
import type { Metadata } from 'next';
16+
import { config } from 'apps/payments/next/config';
1517

16-
export const metadata: Metadata = {
17-
title: 'Action required',
18-
description:
19-
'Please complete the required action to proceed with your payment.',
20-
};
18+
export async function generateMetadata(
19+
{
20+
params,
21+
searchParams,
22+
}: {
23+
params: CheckoutParams;
24+
searchParams: Record<string, string> | undefined;
25+
},
26+
): Promise<Metadata> {
27+
return buildPageMetadata({
28+
params,
29+
titlePrefix: 'Action required',
30+
description: 'Please complete the required action to proceed with your payment.',
31+
page: 'needs_input',
32+
pageType: 'checkout',
33+
acceptLanguage: headers().get('accept-language'),
34+
baseUrl: config.paymentsNextHostedUrl,
35+
searchParams
36+
});
37+
}
2138

2239
export default async function NeedsInputPage({
2340
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/checkout/[cartId]/processing/page.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,34 @@ import {
66
PaymentStateObserver,
77
CheckoutParams,
88
LoadingSpinner,
9+
buildPageMetadata,
910
} from '@fxa/payments/ui';
1011
import { getApp, SupportedPages } from '@fxa/payments/ui/server';
1112
import { headers } from 'next/headers';
1213
import { getCartOrRedirectAction } from '@fxa/payments/ui/actions';
1314
import type { Metadata } from 'next';
15+
import { config } from 'apps/payments/next/config';
1416

15-
export const metadata: Metadata = {
16-
title: 'Processing',
17-
description: 'Please wait while we finish processing your payment.',
18-
};
17+
export async function generateMetadata(
18+
{
19+
params,
20+
searchParams,
21+
}: {
22+
params: CheckoutParams;
23+
searchParams: Record<string, string> | undefined;
24+
},
25+
): Promise<Metadata> {
26+
return buildPageMetadata({
27+
params,
28+
titlePrefix: 'Processing',
29+
description: 'Please wait while we finish processing your payment.',
30+
page: 'processing',
31+
pageType: 'checkout',
32+
acceptLanguage: headers().get('accept-language'),
33+
baseUrl: config.paymentsNextHostedUrl,
34+
searchParams
35+
});
36+
}
1937

2038
export default async function ProcessingPage({
2139
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/checkout/[cartId]/start/page.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ButtonVariant,
1212
PaymentSection,
1313
SignInForm,
14+
buildPageMetadata,
1415
} from '@fxa/payments/ui';
1516
import {
1617
getApp,
@@ -30,10 +31,26 @@ import type { Metadata } from 'next';
3031

3132
export const dynamic = 'force-dynamic';
3233

33-
export const metadata: Metadata = {
34-
title: 'Checkout',
35-
description: 'Enter your payment details to complete your purchase.',
36-
};
34+
export async function generateMetadata(
35+
{
36+
params,
37+
searchParams,
38+
}: {
39+
params: CheckoutParams;
40+
searchParams: Record<string, string> | undefined;
41+
},
42+
): Promise<Metadata> {
43+
return buildPageMetadata({
44+
params,
45+
titlePrefix: 'Checkout',
46+
description: 'Enter your payment details to complete your purchase.',
47+
page: 'start',
48+
pageType: 'checkout',
49+
acceptLanguage: headers().get('accept-language'),
50+
baseUrl: config.paymentsNextHostedUrl,
51+
searchParams
52+
});
53+
}
3754

3855
export default async function Checkout({
3956
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/checkout/[cartId]/success/page.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Metadata } from 'next';
66
import { headers } from 'next/headers';
77
import Image from 'next/image';
88
import { auth } from 'apps/payments/next/auth';
9-
import { getCardIcon } from '@fxa/payments/ui';
9+
import { getCardIcon, buildPageMetadata } from '@fxa/payments/ui';
1010
import {
1111
fetchCMSData,
1212
getCartOrRedirectAction,
@@ -17,14 +17,30 @@ import {
1717
CheckoutParams,
1818
SupportedPages,
1919
} from '@fxa/payments/ui/server';
20+
import { config } from 'apps/payments/next/config';
2021

2122
export const dynamic = 'force-dynamic';
2223

23-
export const metadata: Metadata = {
24-
title: 'Success',
25-
description:
26-
'Congratulations! You have successfully completed your purchase.',
27-
};
24+
export async function generateMetadata(
25+
{
26+
params,
27+
searchParams
28+
}: {
29+
params: CheckoutParams;
30+
searchParams: Record<string, string> | undefined;
31+
},
32+
): Promise<Metadata> {
33+
return buildPageMetadata({
34+
params,
35+
titlePrefix: 'Success',
36+
description: 'Congratulations! You have successfully completed your purchase.',
37+
page: 'success',
38+
pageType: 'checkout',
39+
acceptLanguage: headers().get('accept-language'),
40+
baseUrl: config.paymentsNextHostedUrl,
41+
searchParams
42+
});
43+
}
2844

2945
export default async function CheckoutSuccess({
3046
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/upgrade/[cartId]/(mainLayout)/error/page.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,32 @@ import {
1919
} from '@fxa/payments/ui/actions';
2020
import { config } from 'apps/payments/next/config';
2121
import { Metadata } from 'next';
22+
import { buildPageMetadata } from '@fxa/payments/ui';
2223

2324
// forces dynamic rendering
2425
// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
2526
export const dynamic = 'force-dynamic';
2627

27-
export const metadata: Metadata = {
28-
title: 'Error',
29-
description:
30-
'There was an error processing your upgrade. If this problem persists, please contact support.',
31-
};
28+
export async function generateMetadata(
29+
{
30+
params,
31+
searchParams,
32+
}: {
33+
params: CheckoutParams;
34+
searchParams: Record<string, string> | undefined;
35+
},
36+
): Promise<Metadata> {
37+
return buildPageMetadata({
38+
params,
39+
titlePrefix: 'Error',
40+
description: 'There was an error processing your upgrade. If this problem persists, please contact support.',
41+
page: 'error',
42+
pageType: 'upgrade',
43+
acceptLanguage: headers().get('accept-language'),
44+
baseUrl: config.paymentsNextHostedUrl,
45+
searchParams
46+
});
47+
}
3248

3349
export default async function UpgradeError({
3450
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/upgrade/[cartId]/(mainLayout)/needs_input/page.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,34 @@ import {
77
LoadingSpinner,
88
StripeWrapper,
99
PaymentInputHandler,
10+
buildPageMetadata,
1011
} from '@fxa/payments/ui';
1112
import { getApp, SupportedPages } from '@fxa/payments/ui/server';
1213
import { headers } from 'next/headers';
1314
import { getCartOrRedirectAction } from '@fxa/payments/ui/actions';
1415
import { Metadata } from 'next';
16+
import { config } from 'apps/payments/next/config';
1517

16-
export const metadata: Metadata = {
17-
title: 'Action required',
18-
description:
19-
'Please complete the required action to proceed with your payment.',
20-
};
18+
export async function generateMetadata(
19+
{
20+
params,
21+
searchParams,
22+
}: {
23+
params: CheckoutParams;
24+
searchParams: Record<string, string> | undefined;
25+
},
26+
): Promise<Metadata> {
27+
return buildPageMetadata({
28+
params,
29+
titlePrefix: 'Action required',
30+
description: 'Please complete the required action to proceed with your payment.',
31+
page: 'needs_input',
32+
pageType: 'upgrade',
33+
acceptLanguage: headers().get('accept-language'),
34+
baseUrl: config.paymentsNextHostedUrl,
35+
searchParams
36+
});
37+
}
2138

2239
export default async function NeedsInputPage({
2340
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/upgrade/[cartId]/(mainLayout)/processing/page.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,34 @@ import {
66
PaymentStateObserver,
77
CheckoutParams,
88
LoadingSpinner,
9+
buildPageMetadata,
910
} from '@fxa/payments/ui';
1011
import { getApp, SupportedPages } from '@fxa/payments/ui/server';
1112
import { headers } from 'next/headers';
1213
import { getCartOrRedirectAction } from '@fxa/payments/ui/actions';
1314
import { Metadata } from 'next';
15+
import { config } from 'apps/payments/next/config';
1416

15-
export const metadata: Metadata = {
16-
title: 'Processing',
17-
description: 'Please wait while we finish processing your payment.',
18-
};
17+
export async function generateMetadata(
18+
{
19+
params,
20+
searchParams,
21+
}: {
22+
params: CheckoutParams;
23+
searchParams: Record<string, string> | undefined;
24+
},
25+
): Promise<Metadata> {
26+
return buildPageMetadata({
27+
params,
28+
titlePrefix: 'Processing',
29+
description: 'Please wait while we finish processing your payment.',
30+
page: 'processing',
31+
pageType: 'upgrade',
32+
acceptLanguage: headers().get('accept-language'),
33+
baseUrl: config.paymentsNextHostedUrl,
34+
searchParams
35+
});
36+
}
1937

2038
export default async function ProcessingPage({
2139
params,

apps/payments/next/app/[locale]/[offeringId]/[interval]/upgrade/[cartId]/(mainLayout)/success/page.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { headers } from 'next/headers';
66
import { auth } from 'apps/payments/next/auth';
7-
import { getCardIcon } from '@fxa/payments/ui';
7+
import { getCardIcon, buildPageMetadata } from '@fxa/payments/ui';
88
import { SupportedPages, getApp } from '@fxa/payments/ui/server';
99
import {
1010
fetchCMSData,
@@ -14,13 +14,30 @@ import {
1414
import { CheckoutParams } from '@fxa/payments/ui/server';
1515
import Image from 'next/image';
1616
import { Metadata } from 'next';
17+
import { config } from 'apps/payments/next/config';
1718

1819
export const dynamic = 'force-dynamic';
1920

20-
export const metadata: Metadata = {
21-
title: 'Success',
22-
description: 'Congratulations! You have successfully completed your upgrade.',
23-
};
21+
export async function generateMetadata(
22+
{
23+
params,
24+
searchParams,
25+
}: {
26+
params: CheckoutParams;
27+
searchParams: Record<string, string> | undefined;
28+
},
29+
): Promise<Metadata> {
30+
return buildPageMetadata({
31+
params,
32+
titlePrefix: 'Success',
33+
description: 'Congratulations! You have successfully completed your upgrade.',
34+
page: 'success',
35+
pageType: 'upgrade',
36+
acceptLanguage: headers().get('accept-language'),
37+
baseUrl: config.paymentsNextHostedUrl,
38+
searchParams
39+
});
40+
}
2441

2542
export default async function UpgradeSuccess({
2643
params,

0 commit comments

Comments
 (0)