This commit is contained in:
hailin 2025-04-18 00:02:30 +08:00
parent 27d7709693
commit f7a0cc8e45
1 changed files with 15 additions and 9 deletions

View File

@ -10,14 +10,18 @@ import { Metadata } from "next"
import { cookies, headers } from "next/headers" import { cookies, headers } from "next/headers"
import { redirect } from "next/navigation" import { redirect } from "next/navigation"
import { initTranslations } from "@/lib/i18n";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Login" title: "Login"
} }
export default async function Login({ export default async function Login({
searchParams searchParams,
params: { locale },
}: { }: {
searchParams: { message: string } searchParams: { message: string }
params: { locale: string };
}) { }) {
const cookieStore = cookies() const cookieStore = cookies()
const supabase = createServerClient<Database>( const supabase = createServerClient<Database>(
@ -163,6 +167,8 @@ export default async function Login({
return redirect("/login?message=Check email to reset password") return redirect("/login?message=Check email to reset password")
} }
const { t, resources } = await initTranslations(locale, ['translation']);
return ( return (
<div className="flex w-full flex-1 flex-col justify-center gap-2 px-8 sm:max-w-md"> <div className="flex w-full flex-1 flex-col justify-center gap-2 px-8 sm:max-w-md">
<form <form
@ -172,34 +178,34 @@ export default async function Login({
<Brand /> <Brand />
<Label className="text-md mt-4" htmlFor="email"> <Label className="text-md mt-4" htmlFor="email">
Email {t("login.email")}
</Label> </Label>
<Input <Input
className="mb-3 rounded-md border bg-inherit px-4 py-2" className="mb-3 rounded-md border bg-inherit px-4 py-2"
name="email" name="email"
placeholder="you@example.com" placeholder={t("login.emailPlaceholder")}
required required
/> />
<Label className="text-md" htmlFor="password"> <Label className="text-md" htmlFor="password">
Password {t("login.password")}
</Label> </Label>
<Input <Input
className="mb-6 rounded-md border bg-inherit px-4 py-2" className="mb-6 rounded-md border bg-inherit px-4 py-2"
type="password" type="password"
name="password" name="password"
placeholder="••••••••" placeholder={t("login.passwordPlaceholder")}
/> />
<SubmitButton className="mb-2 rounded-md bg-blue-700 px-4 py-2 text-white"> <SubmitButton className="mb-2 rounded-md bg-blue-700 px-4 py-2 text-white">
Login {t("login.loginButton")}
</SubmitButton> </SubmitButton>
<SubmitButton <SubmitButton
formAction={signUp} formAction={signUp}
className="border-foreground/20 mb-2 rounded-md border px-4 py-2" className="border-foreground/20 mb-2 rounded-md border px-4 py-2"
> >
Sign Up {t("login.signUpButton")}
</SubmitButton> </SubmitButton>
<div className="text-muted-foreground mt-1 flex justify-center text-sm"> <div className="text-muted-foreground mt-1 flex justify-center text-sm">
@ -208,7 +214,7 @@ export default async function Login({
formAction={handleResetPassword} formAction={handleResetPassword}
className="text-primary ml-1 underline hover:opacity-80" className="text-primary ml-1 underline hover:opacity-80"
> >
Reset {t("login.reset")}
</button> </button>
</div> </div>