fix(auth): clear mobile number field automatically when country changes during registration #90

Merged
amit merged 1 commits from fix/clear-phone-on-country-change into main 2026-11-06 05:02:16 +00:00
1 changed files with 14 additions and 10 deletions
Showing only changes of commit 9f08b0a6a5 - Show all commits

View File

@ -294,11 +294,13 @@ export const AuthModal: React.FC<AuthModalProps> = ({
value={authDialCode} value={authDialCode}
onChange={(e) => { onChange={(e) => {
const newCode = e.target.value; const newCode = e.target.value;
if (newCode !== authDialCode) {
setAuthDialCode(newCode); setAuthDialCode(newCode);
const rule = getCountryRuleByDialCode(newCode); const rule = getCountryRuleByDialCode(newCode);
if (rule && rule.country !== 'Other') { if (rule && rule.country !== 'Other') {
setAuthCountry(rule.country); setAuthCountry(rule.country);
setAuthPhone(cleanPhoneInput(authPhone, rule.maxLength, false)); }
setAuthPhone('');
} }
}} }}
className="w-full bg-slate-950 border border-slate-800 rounded-xl px-2.5 py-2.5 text-xs sm:text-sm font-semibold text-white focus:outline-none focus:border-indigo-500 appearance-none pr-6" className="w-full bg-slate-950 border border-slate-800 rounded-xl px-2.5 py-2.5 text-xs sm:text-sm font-semibold text-white focus:outline-none focus:border-indigo-500 appearance-none pr-6"
@ -341,11 +343,13 @@ export const AuthModal: React.FC<AuthModalProps> = ({
value={authCountry} value={authCountry}
onChange={(e) => { onChange={(e) => {
const newCountry = e.target.value; const newCountry = e.target.value;
if (newCountry !== authCountry) {
setAuthCountry(newCountry); setAuthCountry(newCountry);
const rule = getCountryRuleByName(newCountry); const rule = getCountryRuleByName(newCountry);
if (rule) { if (rule) {
setAuthDialCode(rule.code); setAuthDialCode(rule.code);
setAuthPhone(cleanPhoneInput(authPhone, rule.maxLength, false)); }
setAuthPhone('');
} }
}} }}
className="w-full bg-slate-950 border border-slate-800 rounded-xl px-4 py-2.5 text-sm font-semibold text-white focus:outline-none focus:border-indigo-500 appearance-none" className="w-full bg-slate-950 border border-slate-800 rounded-xl px-4 py-2.5 text-sm font-semibold text-white focus:outline-none focus:border-indigo-500 appearance-none"