Skip to content

Commit

Permalink
fix(admin-ui): Fix modification of order addresses
Browse files Browse the repository at this point in the history
Relates to #688
  • Loading branch information
michaelbromley committed Feb 10, 2021
1 parent 7e9a709 commit cd9a812
Showing 1 changed file with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,28 +125,32 @@ export class OrderEditorComponent
taxRate: new FormControl(0),
taxDescription: new FormControl(''),
});
this.shippingAddressForm = new FormGroup({
fullName: new FormControl(order.shippingAddress?.fullName),
company: new FormControl(order.shippingAddress?.company),
streetLine1: new FormControl(order.shippingAddress?.streetLine1),
streetLine2: new FormControl(order.shippingAddress?.streetLine2),
city: new FormControl(order.shippingAddress?.city),
province: new FormControl(order.shippingAddress?.province),
postalCode: new FormControl(order.shippingAddress?.postalCode),
countryCode: new FormControl(order.shippingAddress?.countryCode),
phoneNumber: new FormControl(order.shippingAddress?.phoneNumber),
});
this.billingAddressForm = new FormGroup({
fullName: new FormControl(order.billingAddress?.fullName),
company: new FormControl(order.billingAddress?.company),
streetLine1: new FormControl(order.billingAddress?.streetLine1),
streetLine2: new FormControl(order.billingAddress?.streetLine2),
city: new FormControl(order.billingAddress?.city),
province: new FormControl(order.billingAddress?.province),
postalCode: new FormControl(order.billingAddress?.postalCode),
countryCode: new FormControl(order.billingAddress?.countryCode),
phoneNumber: new FormControl(order.billingAddress?.phoneNumber),
});
if (!this.shippingAddressForm) {
this.shippingAddressForm = new FormGroup({
fullName: new FormControl(order.shippingAddress?.fullName),
company: new FormControl(order.shippingAddress?.company),
streetLine1: new FormControl(order.shippingAddress?.streetLine1),
streetLine2: new FormControl(order.shippingAddress?.streetLine2),
city: new FormControl(order.shippingAddress?.city),
province: new FormControl(order.shippingAddress?.province),
postalCode: new FormControl(order.shippingAddress?.postalCode),
countryCode: new FormControl(order.shippingAddress?.countryCode),
phoneNumber: new FormControl(order.shippingAddress?.phoneNumber),
});
}
if (!this.billingAddressForm) {
this.billingAddressForm = new FormGroup({
fullName: new FormControl(order.billingAddress?.fullName),
company: new FormControl(order.billingAddress?.company),
streetLine1: new FormControl(order.billingAddress?.streetLine1),
streetLine2: new FormControl(order.billingAddress?.streetLine2),
city: new FormControl(order.billingAddress?.city),
province: new FormControl(order.billingAddress?.province),
postalCode: new FormControl(order.billingAddress?.postalCode),
countryCode: new FormControl(order.billingAddress?.countryCode),
phoneNumber: new FormControl(order.billingAddress?.phoneNumber),
});
}
this.orderLineCustomFieldsFormArray = new FormArray([]);
for (const line of order.lines) {
const formGroup = new FormGroup({});
Expand Down Expand Up @@ -341,6 +345,10 @@ export class OrderEditorComponent
previewAndModify(order: OrderDetail.Fragment) {
const input: ModifyOrderInput = {
...this.modifyOrderInput,
...(this.billingAddressForm.dirty ? { updateBillingAddress: this.billingAddressForm.value } : {}),
...(this.shippingAddressForm.dirty
? { updateShippingAddress: this.shippingAddressForm.value }
: {}),
dryRun: true,
note: this.note,
options: {
Expand Down

0 comments on commit cd9a812

Please sign in to comment.