Browse Source

feat(core): Include Customer in CustomerAddressEvent

Closes #1369
Michael Bromley 4 years ago
parent
commit
67f60accb7
1 changed files with 3 additions and 0 deletions
  1. 3 0
      packages/core/src/service/services/customer.service.ts

+ 3 - 0
packages/core/src/service/services/customer.service.ts

@@ -697,6 +697,7 @@ export class CustomerService {
             type: HistoryEntryType.CUSTOMER_ADDRESS_CREATED,
             type: HistoryEntryType.CUSTOMER_ADDRESS_CREATED,
             data: { address: addressToLine(createdAddress) },
             data: { address: addressToLine(createdAddress) },
         });
         });
+        createdAddress.customer = customer;
         this.eventBus.publish(new CustomerAddressEvent(ctx, createdAddress, 'created', input));
         this.eventBus.publish(new CustomerAddressEvent(ctx, createdAddress, 'created', input));
         return createdAddress;
         return createdAddress;
     }
     }
@@ -733,6 +734,7 @@ export class CustomerService {
                 input,
                 input,
             },
             },
         });
         });
+        updatedAddress.customer = customer;
         this.eventBus.publish(new CustomerAddressEvent(ctx, updatedAddress, 'updated', input));
         this.eventBus.publish(new CustomerAddressEvent(ctx, updatedAddress, 'updated', input));
         return updatedAddress;
         return updatedAddress;
     }
     }
@@ -761,6 +763,7 @@ export class CustomerService {
             },
             },
         });
         });
         await this.connection.getRepository(ctx, Address).remove(address);
         await this.connection.getRepository(ctx, Address).remove(address);
+        address.customer = customer;
         this.eventBus.publish(new CustomerAddressEvent(ctx, address, 'deleted', id));
         this.eventBus.publish(new CustomerAddressEvent(ctx, address, 'deleted', id));
         return true;
         return true;
     }
     }