'use client'; import LanguageSwitch from '@/components/language-switch'; import ThemeSwitch from '@/components/theme-switch'; import useGlobalStore from '@/config/use-global'; import { DotLottieReact } from '@lottiefiles/dotlottie-react'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@workspace/ui/components/tabs'; import LoginLottie from '@workspace/ui/lotties/login.json'; import { useTranslations } from 'next-intl'; import Image from 'next/legacy/image'; import Link from 'next/link'; import EmailAuthForm from './email/auth-form'; import PhoneAuthForm from './phone/auth-form'; export default function Page() { const t = useTranslations('auth'); const { common } = useGlobalStore(); const { site, auth } = common; const AUTH_COMPONENT_MAP = { email: , sms: , } as const; type AuthMethod = keyof typeof AUTH_COMPONENT_MAP; const enabledAuthMethods = Object.entries(auth).reduce((acc, [key, value]) => { const enabledKey = `${key}_enabled` as const; if (typeof value === 'object' && value !== null && enabledKey in value) { const enabled = (value as Record)[enabledKey]; if (enabled) acc.push(key as AuthMethod); } return acc; }, []); return (
{site.site_logo && ( logo )} {site.site_name}

{site.site_desc}

{t('verifyAccount')}

{t('verifyAccountDesc')}
{enabledAuthMethods.length === 1 ? AUTH_COMPONENT_MAP[enabledAuthMethods[0] as AuthMethod] : enabledAuthMethods[0] && ( {enabledAuthMethods.map((method) => ( {t(`methods.${method}`)} ))} {enabledAuthMethods.map((method) => ( {AUTH_COMPONENT_MAP[method]} ))} )}
{t('tos')}
); }