Skip to content

Commit

Permalink
fix(admin-ui): Fix notification for customer verification email
Browse files Browse the repository at this point in the history
Relates to #438
  • Loading branch information
michaelbromley committed Aug 18, 2020
1 parent a68b18e commit 6c76ebe
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
this.init();
this.availableCountries$ = this.dataService.settings
.getAvailableCountries()
.mapSingle((result) => result.countries.items)
.mapSingle(result => result.countries.items)
.pipe(shareReplay(1));

const customerWithUpdates$ = this.entity$.pipe(merge(this.orderListUpdates$));
this.orders$ = customerWithUpdates$.pipe(map((customer) => customer.orders.items));
this.ordersCount$ = this.entity$.pipe(map((customer) => customer.orders.totalItems));
this.orders$ = customerWithUpdates$.pipe(map(customer => customer.orders.items));
this.ordersCount$ = this.entity$.pipe(map(customer => customer.orders.totalItems));
this.history$ = this.fetchHistory.pipe(
startWith(null),
switchMap(() => {
Expand All @@ -109,7 +109,7 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
createdAt: SortOrder.DESC,
},
})
.mapStream((data) => data.customer?.history.items);
.mapStream(data => data.customer?.history.items);
}),
);
}
Expand Down Expand Up @@ -182,11 +182,11 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
customFields,
};
this.dataService.customer.createCustomer(customer, formValue.password).subscribe(
(data) => {
data => {
this.notificationService.success(_('common.notify-create-success'), {
entity: 'Customer',
});
if (!formValue.password) {
if (data.createCustomer.emailAddress && !formValue.password) {
this.notificationService.notify({
message: _('customer.email-verification-sent'),
translationVars: { emailAddress: formValue.emailAddress },
Expand All @@ -199,7 +199,7 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
this.changeDetector.markForCheck();
this.router.navigate(['../', data.createCustomer.id], { relativeTo: this.route });
},
(err) => {
err => {
this.notificationService.error(_('common.notify-create-error'), {
entity: 'Customer',
});
Expand Down Expand Up @@ -265,7 +265,7 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
}),
)
.subscribe(
(data) => {
data => {
this.notificationService.success(_('common.notify-update-success'), {
entity: 'Customer',
});
Expand All @@ -274,7 +274,7 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
this.changeDetector.markForCheck();
this.fetchHistory.next();
},
(err) => {
err => {
this.notificationService.error(_('common.notify-update-error'), {
entity: 'Customer',
});
Expand All @@ -288,11 +288,11 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
size: 'md',
})
.pipe(
switchMap((groupIds) => (groupIds ? from(groupIds) : EMPTY)),
concatMap((groupId) => this.dataService.customer.addCustomersToGroup(groupId, [this.id])),
switchMap(groupIds => (groupIds ? from(groupIds) : EMPTY)),
concatMap(groupId => this.dataService.customer.addCustomersToGroup(groupId, [this.id])),
)
.subscribe({
next: (res) => {
next: res => {
this.notificationService.success(_(`customer.add-customers-to-group-success`), {
customerCount: 1,
groupName: res.addCustomersToGroup.name,
Expand All @@ -315,14 +315,14 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
],
})
.pipe(
switchMap((response) =>
switchMap(response =>
response
? this.dataService.customer.removeCustomersFromGroup(group.id, [this.id])
: EMPTY,
),
switchMap(() => this.dataService.customer.getCustomer(this.id, { take: 0 }).single$),
)
.subscribe((result) => {
.subscribe(result => {
this.notificationService.success(_(`customer.remove-customers-from-group-success`), {
customerCount: 1,
groupName: group.name,
Expand Down Expand Up @@ -350,7 +350,7 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
},
})
.pipe(
switchMap((result) => {
switchMap(result => {
if (result) {
return this.dataService.customer.updateCustomerNote({
noteId: entry.id,
Expand All @@ -361,7 +361,7 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
}
}),
)
.subscribe((result) => {
.subscribe(result => {
this.fetchHistory.next();
this.notificationService.success(_('common.notify-update-success'), {
entity: 'Note',
Expand All @@ -379,7 +379,7 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
{ type: 'danger', label: _('common.delete'), returnValue: true },
],
})
.pipe(switchMap((res) => (res ? this.dataService.customer.deleteCustomerNote(entry.id) : EMPTY)))
.pipe(switchMap(res => (res ? this.dataService.customer.deleteCustomerNote(entry.id) : EMPTY)))
.subscribe(() => {
this.fetchHistory.next();
this.notificationService.success(_('common.notify-delete-success'), {
Expand Down Expand Up @@ -441,9 +441,9 @@ export class CustomerDetailComponent extends BaseDetailComponent<CustomerWithOrd
skip: (this.currentOrdersPage - 1) * this.ordersPerPage,
})
.single$.pipe(
map((data) => data.customer),
map(data => data.customer),
filter(notNullOrUndefined),
)
.subscribe((result) => this.orderListUpdates$.next(result));
.subscribe(result => this.orderListUpdates$.next(result));
}
}

0 comments on commit 6c76ebe

Please sign in to comment.