mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-30 02:52:16 +00:00
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:
co-authored by
Elio Bischof
Elio Bischof
parent
36eeae1071
commit
6f82285ad6
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user