Files
juwan-frontend/app/(auth)/forgot-password/page.tsx
T

65 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client"
import { Button } from "@/components/ui/button"
import { IconInput } from "@/components/ui/icon-input"
import { Label } from "@/components/ui/label"
import { notifySuccess } from "@/lib/toast"
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema"
import { Mail } from "lucide-react"
import Link from "next/link"
import { useForm } from "react-hook-form"
import { z } from "zod"
const forgotSchema = z.object({
email: z.string().email("请输入正确的邮箱地址"),
})
export default function ForgotPasswordPage() {
const {
register,
handleSubmit,
formState: { errors, isSubmitting },
} = useForm({
resolver: standardSchemaResolver(forgotSchema),
})
const onSubmit = async (_data: z.infer<typeof forgotSchema>) => {
await new Promise((r) => setTimeout(r, 500))
notifySuccess("重置链接已发送到你的邮箱")
}
return (
<>
<div className="mb-8">
<h2 className="text-2xl font-bold"></h2>
<p className="mt-2 text-sm text-muted-foreground"></p>
</div>
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
<div className="space-y-1.5">
<Label htmlFor="email"></Label>
<IconInput
id="email"
icon={<Mail />}
type="email"
placeholder="输入注册邮箱"
{...register("email")}
/>
{errors.email && <p className="text-xs text-destructive">{errors.email.message}</p>}
</div>
<Button type="submit" className="mt-2 w-full" size="lg" disabled={isSubmitting}>
{isSubmitting ? "发送中..." : "发送重置链接"}
</Button>
</form>
<p className="mt-8 text-center text-sm text-muted-foreground">
{" "}
<Link href="/login" className="font-medium text-primary hover:underline">
</Link>
</p>
</>
)
}