Skip to content

Commit

Permalink
fix(admin-ui): Fix display of Address custom fields in customer detai…
Browse files Browse the repository at this point in the history
…l view

Fixes #2272
  • Loading branch information
michaelbromley committed Jul 12, 2023
1 parent 8f72e1e commit 189e714
Showing 1 changed file with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,6 @@ export class CustomerDetailComponent
this.addressCustomFields.reduce((hash, field) => ({ ...hash, [field.name]: '' }), {}),
),
});
// if (this.addressCustomFields.length) {
// const customFieldsGroup = this.formBuilder.group({});
// for (const fieldDef of this.addressCustomFields) {
// customFieldsGroup.addControl(fieldDef.name, new UntypedFormControl(''));
// }
// newAddress.addControl('customFields', customFieldsGroup);
// }
addressFormArray.push(newAddress);
}

Expand Down Expand Up @@ -495,7 +488,13 @@ export class CustomerDetailComponent
...rest,
countryCode: address.country.code,
customFields: this.formBuilder.group(
this.addressCustomFields.reduce((hash, field) => ({ ...hash, [field.name]: '' }), {}),
this.addressCustomFields.reduce(
(hash, field) => ({
...hash,
[field.name]: address['customFields'][field.name],
}),
{},
),
),
});
addressesArray.push(addressGroup);
Expand All @@ -505,17 +504,6 @@ export class CustomerDetailComponent
if (address.defaultBillingAddress) {
this.defaultBillingAddressId = address.id;
}

if (this.addressCustomFields.length) {
const customFieldsGroup = this.formBuilder.group({});
for (const fieldDef of this.addressCustomFields) {
const key = fieldDef.name;
const value = (address as any).customFields?.[key];
const control = new UntypedFormControl(value);
customFieldsGroup.addControl(key, control);
}
addressGroup.addControl('customFields', customFieldsGroup);
}
}
this.detailForm.setControl('addresses', addressesArray);
}
Expand Down

0 comments on commit 189e714

Please sign in to comment.