fix(auth): add visibility toggle to confirm password and update mismatch error message

This commit is contained in:
Urvish Prajapati 2026-11-11 15:45:34 +05:30
parent 6410d21e66
commit 7f8bd75c99
2 changed files with 19 additions and 9 deletions

View File

@ -500,7 +500,7 @@ export default function App() {
return; return;
} }
if (changeNewPassword !== changeConfirmPassword) { if (changeNewPassword !== changeConfirmPassword) {
setChangePasswordError('New passwords do not match.'); setChangePasswordError('Confirm password do not match.');
return; return;
} }

View File

@ -76,6 +76,7 @@ export const ProfileDrawer: React.FC<ProfileDrawerProps> = ({
}) => { }) => {
const [showOldPassword, setShowOldPassword] = useState(false); const [showOldPassword, setShowOldPassword] = useState(false);
const [showNewPassword, setShowNewPassword] = useState(false); const [showNewPassword, setShowNewPassword] = useState(false);
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
const activeRule = getCountryRuleByName(profileCountry); const activeRule = getCountryRuleByName(profileCountry);
if (!isOpen || !loggedInUser) return null; if (!isOpen || !loggedInUser) return null;
@ -275,14 +276,23 @@ export const ProfileDrawer: React.FC<ProfileDrawerProps> = ({
<div className="space-y-1"> <div className="space-y-1">
<label className="text-xs font-bold text-slate-500">Confirm New Password</label> <label className="text-xs font-bold text-slate-500">Confirm New Password</label>
<div className="relative">
<input <input
type="password" type={showConfirmPassword ? 'text' : 'password'}
required required
value={changeConfirmPassword} value={changeConfirmPassword}
onChange={(e) => setChangeConfirmPassword(e.target.value)} onChange={(e) => setChangeConfirmPassword(e.target.value)}
placeholder="Repeat new password" placeholder="Repeat new password"
className="w-full bg-white border border-slate-200 rounded-xl px-3 py-2 text-xs font-semibold text-slate-800 focus:outline-none focus:border-indigo-500" className="w-full bg-white border border-slate-200 rounded-xl px-3 py-2 pr-10 text-xs font-semibold text-slate-800 focus:outline-none focus:border-indigo-500"
/> />
<button
type="button"
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
className="absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 p-0.5"
>
{showConfirmPassword ? <EyeOff className="h-3.5 w-3.5" /> : <Eye className="h-3.5 w-3.5" />}
</button>
</div>
</div> </div>
<div className="flex flex-wrap gap-2 text-[10px] text-slate-500 pt-1"> <div className="flex flex-wrap gap-2 text-[10px] text-slate-500 pt-1">