fix: country flag and phone now in sync (#6727)

* fix: country flag and phone now in sync

* change default country

---------

Co-authored-by: Elio Bischof <[email protected]>
Co-authored-by: Elio Bischof <[email protected]>
This commit is contained in:
Miguel Cabrerizo
2023-10-24 13:47:44 +00:00
committed by GitHub
co-authored by Elio Bischof Elio Bischof
parent 36eeae1071
commit 6f82285ad6
19 changed files with 102 additions and 40 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
import { CountryCode, parsePhoneNumber } from 'libphonenumber-js';
export function formatPhone(phone: string): { phone: string; country: CountryCode } {
const defaultCountry = 'CH';
export function formatPhone(phone: string): { phone: string; country: CountryCode } | null {
const defaultCountry = 'US';
if (phone) {
try {
@@ -10,10 +10,10 @@ export function formatPhone(phone: string): { phone: string; country: CountryCod
if (phoneNumber) {
return { phone: phoneNumber.formatInternational(), country };
}
} catch (error) {
console.error(error);
} catch (e) {
return null;
}
}
return { phone, country: defaultCountry };
return null;
}