Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zoneless/cli",
"version": "0.1.4",
"version": "0.1.5",
"description": "Provision and manage an agent-operated Zoneless store",
"license": "Apache-2.0",
"repository": {
Expand Down
25 changes: 19 additions & 6 deletions apps/web/src/app/shared/forms/person-form/person-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export class PersonFormComponent implements OnInit, OnChanges {
this.email.set(this.person.email || '');

if (this.person.phone) {
this.ParseAndSetPhone(this.person.phone);
this.ParseAndSetPhone(
this.person.phone,
this.person.address?.country ?? undefined
);
} else {
this.phoneCountryCode.set('US');
this.phoneNumber.set('');
Expand Down Expand Up @@ -176,10 +179,17 @@ export class PersonFormComponent implements OnInit, OnChanges {
this.EmitFormChange();
}

private ParseAndSetPhone(fullPhone: string): void {
const sortedCountries = [...ISO_CODES].sort(
(a, b) => b.dialCode.length - a.dialCode.length
);
private ParseAndSetPhone(
fullPhone: string,
preferredCountryCode?: string
): void {
const sortedCountries = [...ISO_CODES].sort((a, b) => {
const dialCodeLengthDifference = b.dialCode.length - a.dialCode.length;
if (dialCodeLengthDifference !== 0) return dialCodeLengthDifference;
if (a.code === preferredCountryCode) return -1;
if (b.code === preferredCountryCode) return 1;
return 0;
});
for (const country of sortedCountries) {
if (fullPhone.startsWith(country.dialCode)) {
this.phoneCountryCode.set(country.code);
Expand Down Expand Up @@ -609,7 +619,10 @@ export class PersonFormComponent implements OnInit, OnChanges {
if (country) {
this.phoneCountryCode.set(country.code);
}
this.ParseAndSetPhone(TEST_PERSON_DATA.phone);
this.ParseAndSetPhone(
TEST_PERSON_DATA.phone,
TEST_PERSON_DATA.addressCountry
);

this.ValidateAll();
this.EmitFormChange();
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/utils/constants/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const TEST_PERSON_DATA: PersonFormData = {
firstName: 'Tom',
lastName: 'Jones',
email: 'tom.jones@example.com',
phone: '+1 5551234567',
phone: '+1 4155552671',
dobDay: 1,
dobMonth: 1,
dobYear: 1990,
Expand Down
Loading