import { ROUTES } from '@lumina/market/app/navigation'; import { getChannel, readOnServer } from '@lumina/market/server'; import { toChannelUsername } from '@lumina/market/shared/utils'; import type { Metadata } from 'next'; import { notFound, permanentRedirect, redirect } from 'next/navigation'; import { i18n } from '../../../../i18n'; import { CheckoutTemplate } from './templates/checkout-template'; type CheckoutPageProps = { params: Promise<{ username: string }> }; export const metadata: Metadata = { title: i18n.t('payment:checkout.title'), robots: { index: false }, }; /** * Checkout for a creator's channel (U9), reached only from its «اشتراک». The server renders the * same page for everyone: the bar and who is being paid; the investor's own checkout loads in the * browser. Another spelling of the username redirects to the stored one; a suspended channel * sends the visitor to the channel, which says it is unavailable. */ export default async function CheckoutPage({ params }: CheckoutPageProps) { const segment = (await params).username; const username = toChannelUsername(segment); if (!username) notFound(); if (username !== segment) permanentRedirect(ROUTES.checkout(username)); const channel = await readOnServer(() => getChannel(username)); if (channel.status !== 'ok') notFound(); if (channel.data.suspended) redirect(ROUTES.channel(username)); return ; }