diff --git a/apps/frontend/app/dashboard/profile/page.tsx b/apps/frontend/app/dashboard/profile/page.tsx index 13249e2..1dee34b 100644 --- a/apps/frontend/app/dashboard/profile/page.tsx +++ b/apps/frontend/app/dashboard/profile/page.tsx @@ -63,6 +63,11 @@ export default function ProfilePage() { // Password form const passwordForm = useForm({ resolver: zodResolver(passwordSchema), + defaultValues: { + currentPassword: '', + newPassword: '', + confirmPassword: '', + }, }); // Update form values when user data loads @@ -77,6 +82,18 @@ export default function ProfilePage() { // eslint-disable-next-line react-hooks/exhaustive-deps }, [user]); + // Reset password form when switching to password tab + useEffect(() => { + if (activeTab === 'password') { + passwordForm.reset({ + currentPassword: '', + newPassword: '', + confirmPassword: '', + }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [activeTab]); + // Update profile mutation const updateProfileMutation = useMutation({ mutationFn: (data: ProfileFormData) => { @@ -107,7 +124,11 @@ export default function ProfilePage() { onSuccess: () => { setSuccessMessage('Password updated successfully!'); setErrorMessage(''); - passwordForm.reset(); + passwordForm.reset({ + currentPassword: '', + newPassword: '', + confirmPassword: '', + }); setTimeout(() => setSuccessMessage(''), 3000); }, onError: (error: any) => { @@ -330,6 +351,7 @@ export default function ProfilePage() { {...passwordForm.register('currentPassword')} type="password" id="currentPassword" + autoComplete="current-password" className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> {passwordForm.formState.errors.currentPassword && ( @@ -351,6 +373,7 @@ export default function ProfilePage() { {...passwordForm.register('newPassword')} type="password" id="newPassword" + autoComplete="new-password" className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> {passwordForm.formState.errors.newPassword && ( @@ -376,6 +399,7 @@ export default function ProfilePage() { {...passwordForm.register('confirmPassword')} type="password" id="confirmPassword" + autoComplete="new-password" className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" /> {passwordForm.formState.errors.confirmPassword && (