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

This commit is contained in:
Urvish Prajapati 2026-11-05 15:29:53 +05:30
parent 2a2a95ecf0
commit 9f08b0a6a5
1 changed files with 14 additions and 10 deletions

View File

@ -294,11 +294,13 @@ export const AuthModal: React.FC<AuthModalProps> = ({
value={authDialCode}
onChange={(e) => {
const newCode = e.target.value;
setAuthDialCode(newCode);
const rule = getCountryRuleByDialCode(newCode);
if (rule && rule.country !== 'Other') {
setAuthCountry(rule.country);
setAuthPhone(cleanPhoneInput(authPhone, rule.maxLength, false));
if (newCode !== authDialCode) {
setAuthDialCode(newCode);
const rule = getCountryRuleByDialCode(newCode);
if (rule && rule.country !== 'Other') {
setAuthCountry(rule.country);
}
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"
@ -341,11 +343,13 @@ export const AuthModal: React.FC<AuthModalProps> = ({
value={authCountry}
onChange={(e) => {
const newCountry = e.target.value;
setAuthCountry(newCountry);
const rule = getCountryRuleByName(newCountry);
if (rule) {
setAuthDialCode(rule.code);
setAuthPhone(cleanPhoneInput(authPhone, rule.maxLength, false));
if (newCountry !== authCountry) {
setAuthCountry(newCountry);
const rule = getCountryRuleByName(newCountry);
if (rule) {
setAuthDialCode(rule.code);
}
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"