fix(payments-next): Move searchParams to params

This commit is contained in:
Lisa Chan 2024-03-27 17:13:35 -04:00
Родитель 89d4e28238
Коммит bcbb9e7a72
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9052E177BBC5E764
27 изменённых файлов: 141 добавлений и 39 удалений

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { headers } from 'next/headers';
import Image from 'next/image';
import Link from 'next/link';
@ -5,10 +9,12 @@ import Link from 'next/link';
import { PurchaseDetails, TermsAndPrivacy } from '@fxa/payments/ui/server';
import { getBundle, getLocaleFromRequest } from '@fxa/shared/l10n';
import { getCartData, getContentfulContent } from '../../../../_lib/apiClient';
import checkLogo from '../../../../../images/check.svg';
import errorIcon from '../../../../../images/error.svg';
import { CheckoutSearchParams } from '../../layout';
import {
getCartData,
getContentfulContent,
} from '../../../../../../_lib/apiClient';
import checkLogo from '../../../../../../../images/check.svg';
import errorIcon from '../../../../../../../images/error.svg';
// import { app } from '../../_nestapp/app';
// forces dynamic rendering
@ -19,20 +25,20 @@ export const dynamic = 'force-dynamic';
const demoSupportedLanguages = ['en-US', 'fr-FR', 'es-ES', 'de-DE'];
interface CheckoutParams {
offeringId: string;
cartId: string;
locale: string;
interval: string;
offeringId: string;
}
export default async function CheckoutError({
params,
searchParams,
}: {
params: CheckoutParams;
searchParams: CheckoutSearchParams;
}) {
const headersList = headers();
const locale = getLocaleFromRequest(
searchParams,
params,
headersList.get('accept-language'),
demoSupportedLanguages
);

Просмотреть файл

@ -1,28 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { PurchaseDetails, TermsAndPrivacy } from '@fxa/payments/ui/server';
import { getCartData, getContentfulContent } from '../../../_lib/apiClient';
import {
getCartData,
getContentfulContent,
} from '../../../../../_lib/apiClient';
import { app } from '@fxa/payments/ui/server';
import { headers } from 'next/headers';
import { getLocaleFromRequest } from '@fxa/shared/l10n';
import { CheckoutSearchParams } from '../layout';
import { auth, signIn, signOut } from 'apps/payments/next/auth';
export const dynamic = 'force-dynamic';
interface CheckoutParams {
offeringId: string;
cartId: string;
locale: string;
interval: string;
offeringId: string;
}
export default async function Checkout({
params,
searchParams,
}: {
params: CheckoutParams;
searchParams: CheckoutSearchParams;
}) {
export default async function Checkout({ params }: { params: CheckoutParams }) {
const headersList = headers();
const locale = getLocaleFromRequest(
searchParams,
params,
headersList.get('accept-language')
);

Просмотреть файл

@ -1,10 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { PurchaseDetails, TermsAndPrivacy } from '@fxa/payments/ui/server';
import { getCartData, getContentfulContent } from '../../../../_lib/apiClient';
import {
getCartData,
getContentfulContent,
} from '../../../../../../_lib/apiClient';
import { headers } from 'next/headers';
import Image from 'next/image';
import checkLogo from '../../../../../images/check.svg';
import circledConfirm from '../../../../../images/circled-confirm.svg';
import { formatPlanPricing } from '../../../../../../../../libs/payments/ui/src/lib/utils/helpers';
import checkLogo from '../../../../../../../images/check.svg';
import circledConfirm from '../../../../../../../images/circled-confirm.svg';
import { formatPlanPricing } from '@fxa/payments/ui';
import {
getBundle,
getFormattedMsg,
@ -13,7 +20,6 @@ import {
getLocalizedDate,
getLocalizedDateString,
} from '@fxa/shared/l10n';
import { CheckoutSearchParams } from '../../layout';
// import { app } from '../../_nestapp/app';
export const dynamic = 'force-dynamic';
@ -44,20 +50,20 @@ const ConfirmationDetail = ({
};
interface CheckoutParams {
offeringId: string;
cartId: string;
locale: string;
interval: string;
offeringId: string;
}
export default async function CheckoutSuccess({
params,
searchParams,
}: {
params: CheckoutParams;
searchParams: CheckoutSearchParams;
}) {
const headersList = headers();
const locale = getLocaleFromRequest(
searchParams,
params,
headersList.get('accept-language'),
demoSupportedLanguages
);

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// TODO - Replace these placeholders as part of FXA-8227
export const metadata = {
title: 'Mozilla accounts',
@ -5,10 +9,8 @@ export const metadata = {
};
export interface CheckoutSearchParams {
interval?: string;
promotion_code?: string;
experiment?: string;
locale?: string;
promotion_code?: string;
}
export default function RootLayout({

Просмотреть файл

@ -0,0 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
export default async function CheckoutNew() {
return <></>;
}

Просмотреть файл

@ -1,3 +0,0 @@
export default async function CheckoutNew() {
return <></>;
}

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { fetchCartData, fetchFromContentful } from './stubs';
export async function getCartData(cartId: string) {

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
*
* Temporary File

Просмотреть файл

@ -1 +1,5 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
export { GET, POST } from '../../../../auth';

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Image from 'next/image';
// TODO - Move shared SVGs to a shared library in fxa/libs/shared/*
import mozillaLogo from '../images/moz-logo-bw-rgb.svg';

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Link from 'next/link';
export default function Index() {
@ -14,7 +18,7 @@ export default function Index() {
<h2>123Done - Monthly</h2>
<Link
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
href="/123done/checkout/b6115e72-2a3f-4de8-a58a-e231bfeea85d?interval=monthly"
href="/en/123done/checkout/monthly/b6115e72-2a3f-4de8-a58a-e231bfeea85d"
>
Redirect
</Link>
@ -23,7 +27,7 @@ export default function Index() {
<h2>123Done - Yearly</h2>
<Link
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
href="/123done/checkout/b6115e72-2a3f-4de8-a58a-e231bfeea85d?interval=yearly"
href="/en/123done/checkout/yearly/b6115e72-2a3f-4de8-a58a-e231bfeea85d"
>
Redirect
</Link>

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import type { NextAuthConfig } from 'next-auth';
export const authConfig = {

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import NextAuth from 'next-auth';
import { authConfig } from './auth.config';

4
apps/payments/next/index.d.ts поставляемый
Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable @typescript-eslint/no-explicit-any */
declare module '*.svg' {
const content: any;

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable */
export default {
displayName: 'payments-next',

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//@ts-check
// eslint-disable-next-line @typescript-eslint/no-var-requires

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { join } = require('path');
module.exports = {

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { createGlobPatternsForDependencies } from '@nx/react/tailwind';
import { join } from 'path';
import type { Config } from 'tailwindcss';

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import Index from '../../app/page';

Просмотреть файл

@ -1 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Use this file to export React client components (e.g. those with 'use client' directive) or other non-server utilities
export * from './lib/utils/helpers';

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { Invoice } from '@fxa/payments/cart';
import {
getFormattedMsg,

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { FluentBundle } from '@fluent/bundle';
import { getBundle } from '@fxa/shared/l10n';
import {

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { getLocalizedCurrencyString } from '@fxa/shared/l10n';
import { Stripe } from 'stripe';

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable-next-line */
export type GenericTermsListItem = {
key: string;

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Use this file to export React server components
export * from './lib/server/purchase-details';
export * from './lib/server/terms-and-privacy';

Просмотреть файл

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@import '../../../../shared/assets/src/styles/containers.css';
/* Purchase Details */

Просмотреть файл

@ -11,12 +11,12 @@ import { parseAcceptLanguage } from './parse-accept-language';
* @returns The best fitting locale
*/
export function getLocaleFromRequest(
searchParams: { locale?: string },
params: { locale?: string },
acceptLanguage: string | null,
supportedLanguages?: string[]
) {
if (searchParams.locale) {
return determineLocale(searchParams?.locale, supportedLanguages);
if (params.locale) {
return determineLocale(params?.locale, supportedLanguages);
}
if (acceptLanguage) {