"use client"; import { useState } from "react"; import Link from "next/link"; import { Loader2, MailCheck } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { authClient } from "@/lib/auth/auth-client"; export function ForgotPasswordForm() { const [loading, setLoading] = useState(false); const [sent, setSent] = useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); const form = new FormData(e.currentTarget); const { error } = await authClient.requestPasswordReset({ email: String(form.get("email")), redirectTo: "/reset-password", }); setLoading(false); if (error) { toast.error(error.message ?? "Something went wrong"); return; } setSent(true); } if (sent) { return ( Check your inbox If an account exists for that email, we've sent a reset link. ); } return ( Forgot your password? Enter your email and we'll send you a reset link.

Back to sign in

); }