"use client"; import { Suspense, useState } from "react"; import { useSearchParams } from "next/navigation"; import Link from "next/link"; import { Activity, Loader2 } from "lucide-react"; import { cn } from "@/lib/utils"; export default function ResetPasswordPage() { return ( ); } function ResetPasswordForm() { const searchParams = useSearchParams(); const token = searchParams.get("token"); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); const [success, setSuccess] = useState(false); const passwordValid = password.length >= 8; const passwordsMatch = password === confirmPassword; async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(""); if (!passwordValid) { setError("Password must be at least 8 characters"); return; } if (!passwordsMatch) { setError("Passwords do not match"); return; } if (!token) { setError("Invalid reset link"); return; } setLoading(true); try { const res = await fetch("/api/auth/reset-password", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token, password }), }); if (!res.ok) { const data: { error?: string } = await res.json(); setError(data.error ?? "Something went wrong"); setLoading(false); return; } setSuccess(true); } catch { setError("Something went wrong. Please try again."); setLoading(false); } } if (!token) { return (

Invalid reset link

This password reset link is invalid or has expired.

Request a new reset link

); } if (success) { return (

Password reset

Your password has been successfully reset.

Sign in with your new password

); } return (

Set new password

Enter your new password below

setPassword(e.target.value)} placeholder="••••••••" className={cn( "w-full px-3 py-2.5 bg-neutral-950 border rounded-lg text-sm text-neutral-100 placeholder-neutral-500 outline-none transition-colors", password && !passwordValid ? "border-red-500/50 focus:border-red-500" : "border-neutral-800 focus:border-emerald-500" )} /> {password && !passwordValid && (

Password must be at least 8 characters

)}
setConfirmPassword(e.target.value)} placeholder="••••••••" className={cn( "w-full px-3 py-2.5 bg-neutral-950 border rounded-lg text-sm text-neutral-100 placeholder-neutral-500 outline-none transition-colors", confirmPassword && !passwordsMatch ? "border-red-500/50 focus:border-red-500" : "border-neutral-800 focus:border-emerald-500" )} /> {confirmPassword && !passwordsMatch && (

Passwords do not match

)}
{error && (

{error}

)}

Remember your password?{" "} Sign in

); }