"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useSearchParams } from "next/navigation"; import { useState, useEffect, Suspense } from "react"; import { AlertCircle, ArrowLeft, CheckCircle } from "lucide-react"; import { Input } from "@/components/ui/input"; import { SubmitButton } from "@/components/ui/submit-button"; import { resetPassword } from "../actions"; function ResetPasswordContent() { const router = useRouter(); const searchParams = useSearchParams(); const code = searchParams.get("code"); const [resetSuccess, setResetSuccess] = useState(false); const [errorMessage, setErrorMessage] = useState(null); // Check if code is present in URL useEffect(() => { if (!code) { setErrorMessage("Invalid or missing reset code. Please request a new password reset link."); } }, [code]); const handleResetPassword = async (prevState: any, formData: FormData) => { if (!code) { return { message: "Invalid reset code" }; } const result = await resetPassword(prevState, formData); if (result && typeof result === 'object' && 'success' in result && result.success) { setResetSuccess(true); return result; } return result; }; if (resetSuccess) { return (
{/* Success content */}

Password Reset Complete

Your password has been successfully updated. You can now sign in with your new password.

Go to sign in
); } return (
{/* Header content */}
Back to sign in

Reset Password

Create a new password for your account

{/* Form card */}
{errorMessage && (
{errorMessage}
)} {!errorMessage && (
Reset Password
)} {errorMessage && (
Return to sign in
)}
); } export default function ResetPassword() { return (
}>
); }