d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
import { StateAction, StateActions, StateShell } from '@/components/app-shell/StateShell';
|
|
import { SignInForm } from '@/components/auth/SignInForm';
|
|
import { ForgotPasswordForm } from '@/components/auth/ForgotPasswordForm';
|
|
import { ResetPasswordForm } from '@/components/auth/ResetPasswordForm';
|
|
import {
|
|
isLocale,
|
|
localizedPath,
|
|
routeIdFromSlug,
|
|
type Locale,
|
|
type RouteId,
|
|
} from '@/lib/localization/config';
|
|
import { getMessages, type ShellMessages } from '@/lib/localization/messages';
|
|
import { buildLocalizedMetadata } from '@/lib/metadata/build-metadata';
|
|
import type { Metadata } from 'next';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
interface PendingRouteProps {
|
|
params: Promise<{ locale: string; slug: string }>;
|
|
}
|
|
|
|
function routeLabel(messages: ShellMessages, routeId: RouteId): string {
|
|
const labels = messages.footer.links;
|
|
switch (routeId) {
|
|
case 'sign-in':
|
|
return labels.login;
|
|
case 'forgot-password':
|
|
return 'Forgot password';
|
|
case 'reset-password':
|
|
return 'Reset password';
|
|
case 'privacy':
|
|
return labels.privacy;
|
|
case 'terms':
|
|
return labels.terms;
|
|
case 'accessibility':
|
|
return labels.accessibility;
|
|
case 'home':
|
|
return 'RentalDriveGo';
|
|
}
|
|
}
|
|
|
|
async function resolveParams(params: PendingRouteProps['params']) {
|
|
const { locale: localeValue, slug } = await params;
|
|
if (!isLocale(localeValue)) notFound();
|
|
const routeId = routeIdFromSlug(localeValue, slug);
|
|
if (!routeId || routeId === 'home') notFound();
|
|
return { locale: localeValue as Locale, routeId };
|
|
}
|
|
|
|
export async function generateMetadata({ params }: PendingRouteProps): Promise<Metadata> {
|
|
const { locale, routeId } = await resolveParams(params);
|
|
const messages = getMessages(locale).shell;
|
|
const label = routeLabel(messages, routeId);
|
|
return buildLocalizedMetadata({
|
|
locale,
|
|
routeId,
|
|
title: `${label} | ${messages.metadata.pendingTitle}`,
|
|
description: messages.metadata.pendingDescription,
|
|
indexable: false,
|
|
});
|
|
}
|
|
|
|
export default async function PendingRoute({ params }: PendingRouteProps) {
|
|
const { locale, routeId } = await resolveParams(params);
|
|
const messages = getMessages(locale).shell;
|
|
const label = routeLabel(messages, routeId);
|
|
|
|
if (routeId === 'sign-in') {
|
|
return <SignInForm locale={locale} />;
|
|
}
|
|
|
|
if (routeId === 'forgot-password') {
|
|
return <ForgotPasswordForm locale={locale} />;
|
|
}
|
|
|
|
if (routeId === 'reset-password') {
|
|
return <ResetPasswordForm locale={locale} />;
|
|
}
|
|
|
|
return (
|
|
<StateShell
|
|
title={`${label}: ${messages.states.pendingTitle}`}
|
|
body={messages.states.pendingBody}
|
|
>
|
|
<StateActions>
|
|
<StateAction href={localizedPath('home', locale)}>{messages.states.backHome}</StateAction>
|
|
</StateActions>
|
|
</StateShell>
|
|
);
|
|
}
|