#1576 Routing zu Customer Search bei Rechnungsadresse ändern

This commit is contained in:
Andreas Schickinger
2021-03-25 16:26:08 +01:00
parent eabba753a1
commit 35a424a78e

View File

@@ -336,25 +336,30 @@ export class CheckoutReviewComponent {
const processId = this.applicationService.activatedProcessId;
const customer = await this.domainCheckoutService.getBuyer({ processId }).pipe(first()).toPromise();
if (!customer) {
this.navigateToCustomerSearch(processId);
return;
}
const customerId = customer.source;
this.router.navigate(['/customer', `${customerId}`]);
}
async navigateToCustomerSearch(processId: number) {
const response = await this.customerFeatures$
.pipe(
first(),
switchMap((customerFeatures) => {
return this.domainCheckoutService.canSetCustomer({ processId, customerFeatures });
})
)
.toPromise();
this.router.navigate(['/customer', 'search'], { queryParams: { customertype: response.filter.customertype } });
}
async order() {
const processId = this.applicationService.activatedProcessId;
const customer = await this.domainCheckoutService.getBuyer({ processId }).pipe(first()).toPromise();
if (!customer) {
const response = await this.customerFeatures$
.pipe(
first(),
switchMap((customerFeatures) => {
return this.domainCheckoutService.canSetCustomer({ processId, customerFeatures });
})
)
.toPromise();
this.router.navigate(['/customer', 'search'], { queryParams: { customertype: response.filter.customertype } });
this.navigateToCustomerSearch(processId);
} else {
this.showOrderButtonSpinner = true;
this.domainCheckoutService.completeCheckout({ processId }).subscribe(async () => {