'use client'; import React, { useEffect, useState } from 'react'; import axios from 'axios'; import { useRouter } from 'next/navigation'; import IconLockDots from '@/components/icon/icon-lock-dots'; import Link from 'next/link'; import { ApiServerBaseUrl } from '@/utils/baseurl.utils'; import { Eye, EyeOff } from 'lucide-react'; const ComponentsAuthChangePasswordForm = () => { const router = useRouter(); const [email, setEmail] = useState(null); const [currentPassword, setCurrentPassword] = useState(''); const [newPassword, setNewPassword] = useState(''); const [showCurrent, setShowCurrent] = useState(false); const [showNew, setShowNew] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [success, setSuccess] = useState(''); useEffect(() => { const storedEmail = localStorage.getItem('user_email'); if (!storedEmail) { setError('User not authenticated. Please login again.'); setTimeout(() => router.push('/login'), 1500); } else { setEmail(storedEmail); } }, [router]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setSuccess(''); if (!email || !currentPassword || !newPassword) { setError('All fields are required'); return; } try { setLoading(true); await axios.post(`${ApiServerBaseUrl}/change-password`, { email, currentPassword, newPassword, }); setSuccess('Password changed successfully'); setTimeout(() => router.push('/login'), 1500); } catch (err: any) { setError(err.response?.data?.error || 'Password change failed'); } finally { setLoading(false); } }; return (

Change Password

Update your account password

{error &&

{error}

} {success &&

{success}

} {email && (
Signed in as {email}
)} {/* CURRENT PASSWORD */}
setCurrentPassword(e.target.value)} /> {/* 🔥 FIXED EYE ICON — NO MOVING */}
{/* NEW PASSWORD */}
setNewPassword(e.target.value)} /> {/* 🔥 FIXED EYE ICON — NO MOVING */}

Back to{" "} Login

); }; export default ComponentsAuthChangePasswordForm;