'use client'; import { useState } from 'react'; import axios from 'axios'; import { useSearchParams, useRouter } from 'next/navigation'; import { ApiServerBaseUrl } from '@/utils/baseurl.utils'; // Import lucide icons directly import { Eye, EyeOff } from 'lucide-react'; export default function ResetPasswordPage() { const router = useRouter(); const searchParams = useSearchParams(); const token = searchParams.get('token'); const email_user = searchParams.get('email'); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); // 👁️ Toggles const [showPassword, setShowPassword] = useState(false); const [showConfirm, setShowConfirm] = useState(false); const [msg, setMsg] = useState(''); const [err, setErr] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setErr(''); setMsg(''); if (!password || !confirmPassword) { setErr('Please fill all fields'); return; } if (password !== confirmPassword) { setErr('Passwords do not match'); return; } if (!token) { setErr('Invalid or expired token'); return; } setLoading(true); try { await axios.post(`${ApiServerBaseUrl}/auth/reset-password`, { email: email_user, token, newPassword: password, }); setMsg('Password reset successfully! Redirecting to login...'); setTimeout(() => router.push('/login'), 2000); } catch (error: any) { setErr(error.response?.data?.error || 'Something went wrong'); } finally { setLoading(false); } }; return (
{/* Background glows */}
{/* Card */}
{/* Logo */}
Logo

Reset Your Password

Enter your new password below

{err &&

{err}

} {msg &&

{msg}

}
{/* 🔥 NEW PASSWORD FIELD */}
setPassword(e.target.value)} className="w-full bg-[#0a0b17] border border-gray-700 text-white rounded-lg px-4 py-3 pr-12 focus:outline-none focus:border-blue-500" /> {/* Eye Toggle */}
{/* 🔥 CONFIRM PASSWORD FIELD */}
setConfirmPassword(e.target.value)} className="w-full bg-[#0a0b17] border border-gray-700 text-white rounded-lg px-4 py-3 pr-12 focus:outline-none focus:border-blue-500" /> {/* Eye Toggle */}
{/* Button */}
); }