diff --git a/apps/scandic-web/components/Forms/Edit/Profile/schema.ts b/apps/scandic-web/components/Forms/Edit/Profile/schema.ts index 798ddb43f..a0d4bcd43 100644 --- a/apps/scandic-web/components/Forms/Edit/Profile/schema.ts +++ b/apps/scandic-web/components/Forms/Edit/Profile/schema.ts @@ -38,7 +38,7 @@ export const editProfileSchema = z editProfileErrors.PHONE_REQUIRED, editProfileErrors.PHONE_REQUESTED ), - phoneNumberCC: z.string(), + phoneNumberCC: z.string().nullish(), password: z.string().optional(), newPassword: z.literal("").optional().or(passwordValidator()), diff --git a/apps/scandic-web/utils/phone.ts b/apps/scandic-web/utils/phone.ts index 351a1425b..b7c19ea88 100644 --- a/apps/scandic-web/utils/phone.ts +++ b/apps/scandic-web/utils/phone.ts @@ -1,7 +1,10 @@ import parsePhoneNumberFromString, { type CountryCode } from "libphonenumber-js" -export function formatPhoneNumber(phoneNumber: string, phoneNumberCC: string) { - const parsedPhonenumber = phoneNumberCC.length +export function formatPhoneNumber( + phoneNumber: string, + phoneNumberCC?: string | null +): string { + const parsedPhonenumber = phoneNumberCC?.length ? parsePhoneNumberFromString( phoneNumber, phoneNumberCC.toUpperCase() as CountryCode