mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
hotfix(checkout): Chaning the Quantity in the cart used a wrink branch for "Rücklage"
- When chaning the quantity, the current destination branch will be used to update the quantity in the cart
This commit is contained in:
committed by
Lorenz Hilpert
parent
7743150652
commit
4478e1ce21
@@ -9,37 +9,53 @@ import {
|
||||
AfterViewInit,
|
||||
TrackByFunction,
|
||||
inject,
|
||||
} from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ApplicationService } from '@core/application';
|
||||
import { DomainAvailabilityService } from '@domain/availability';
|
||||
import { DomainCheckoutService } from '@domain/checkout';
|
||||
import { AvailabilityDTO, BranchDTO, DestinationDTO, ShoppingCartItemDTO } from '@generated/swagger/checkout-api';
|
||||
import { UiMessageModalComponent, UiModalService } from '@ui/modal';
|
||||
import { PrintModalData, PrintModalComponent } from '@modal/printer';
|
||||
import { delay, first, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
||||
import { Subject, NEVER, combineLatest, BehaviorSubject, Subscription } from 'rxjs';
|
||||
import { DomainCatalogService } from '@domain/catalog';
|
||||
import { BreadcrumbService } from '@core/breadcrumb';
|
||||
import { DomainPrinterService } from '@domain/printer';
|
||||
import { CheckoutDummyComponent } from '../checkout-dummy/checkout-dummy.component';
|
||||
import { CheckoutDummyData } from '../checkout-dummy/checkout-dummy-data';
|
||||
import { PurchaseOptionsModalService } from '@modal/purchase-options';
|
||||
import { CheckoutNavigationService, ProductCatalogNavigationService } from '@shared/services/navigation';
|
||||
import { EnvironmentService } from '@core/environment';
|
||||
import { CheckoutReviewStore } from './checkout-review.store';
|
||||
import { ToasterService } from '@shared/shell';
|
||||
import { ShoppingCartItemComponent } from './shopping-cart-item/shopping-cart-item.component';
|
||||
import { CustomerSearchNavigation } from '@shared/services/navigation';
|
||||
} from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { ApplicationService } from "@core/application";
|
||||
import { DomainAvailabilityService } from "@domain/availability";
|
||||
import { DomainCheckoutService } from "@domain/checkout";
|
||||
import {
|
||||
AvailabilityDTO,
|
||||
BranchDTO,
|
||||
DestinationDTO,
|
||||
ShoppingCartItemDTO,
|
||||
} from "@generated/swagger/checkout-api";
|
||||
import { UiMessageModalComponent, UiModalService } from "@ui/modal";
|
||||
import { PrintModalData, PrintModalComponent } from "@modal/printer";
|
||||
import { delay, first, map, switchMap, takeUntil, tap } from "rxjs/operators";
|
||||
import {
|
||||
Subject,
|
||||
NEVER,
|
||||
combineLatest,
|
||||
BehaviorSubject,
|
||||
Subscription,
|
||||
} from "rxjs";
|
||||
import { DomainCatalogService } from "@domain/catalog";
|
||||
import { BreadcrumbService } from "@core/breadcrumb";
|
||||
import { DomainPrinterService } from "@domain/printer";
|
||||
import { CheckoutDummyComponent } from "../checkout-dummy/checkout-dummy.component";
|
||||
import { CheckoutDummyData } from "../checkout-dummy/checkout-dummy-data";
|
||||
import { PurchaseOptionsModalService } from "@modal/purchase-options";
|
||||
import {
|
||||
CheckoutNavigationService,
|
||||
ProductCatalogNavigationService,
|
||||
} from "@shared/services/navigation";
|
||||
import { EnvironmentService } from "@core/environment";
|
||||
import { CheckoutReviewStore } from "./checkout-review.store";
|
||||
import { ToasterService } from "@shared/shell";
|
||||
import { ShoppingCartItemComponent } from "./shopping-cart-item/shopping-cart-item.component";
|
||||
import { CustomerSearchNavigation } from "@shared/services/navigation";
|
||||
|
||||
@Component({
|
||||
selector: 'page-checkout-review',
|
||||
templateUrl: 'checkout-review.component.html',
|
||||
styleUrls: ['checkout-review.component.scss'],
|
||||
selector: "page-checkout-review",
|
||||
templateUrl: "checkout-review.component.html",
|
||||
styleUrls: ["checkout-review.component.scss"],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
standalone: false,
|
||||
})
|
||||
export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
export class CheckoutReviewComponent
|
||||
implements OnInit, OnDestroy, AfterViewInit
|
||||
{
|
||||
private _onDestroy$ = new Subject<void>();
|
||||
|
||||
private _customerSearchNavigation = inject(CustomerSearchNavigation);
|
||||
@@ -57,7 +73,9 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
|
||||
shoppingCartItemsWithoutOrderType$ = this._store.shoppingCartItems$.pipe(
|
||||
takeUntil(this._store.orderCompleted),
|
||||
map((items) => items?.filter((item) => item?.features?.orderType === undefined)),
|
||||
map((items) =>
|
||||
items?.filter((item) => item?.features?.orderType === undefined),
|
||||
),
|
||||
);
|
||||
|
||||
trackByGroupedItems: TrackByFunction<{
|
||||
@@ -71,11 +89,11 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
map((items) =>
|
||||
items.reduce(
|
||||
(grouped, item) => {
|
||||
let index = grouped.findIndex((g) =>
|
||||
item?.availability?.supplyChannel === 'MANUALLY'
|
||||
? g?.orderType === 'Dummy'
|
||||
: item?.features?.orderType === 'DIG-Versand'
|
||||
? g?.orderType === 'Versand'
|
||||
const index = grouped.findIndex((g) =>
|
||||
item?.availability?.supplyChannel === "MANUALLY"
|
||||
? g?.orderType === "Dummy"
|
||||
: item?.features?.orderType === "DIG-Versand"
|
||||
? g?.orderType === "Versand"
|
||||
: g?.orderType === item?.features?.orderType,
|
||||
);
|
||||
|
||||
@@ -83,10 +101,10 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
if (!group) {
|
||||
group = {
|
||||
orderType:
|
||||
item?.availability?.supplyChannel === 'MANUALLY'
|
||||
? 'Dummy'
|
||||
: item?.features?.orderType === 'DIG-Versand'
|
||||
? 'Versand'
|
||||
item?.availability?.supplyChannel === "MANUALLY"
|
||||
? "Dummy"
|
||||
: item?.features?.orderType === "DIG-Versand"
|
||||
? "Versand"
|
||||
: item?.features?.orderType,
|
||||
destination: item?.destination?.data,
|
||||
items: [],
|
||||
@@ -95,7 +113,8 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
|
||||
group.items = [...group.items, item]?.sort(
|
||||
(a, b) =>
|
||||
a.destination?.data?.targetBranch?.id - b.destination?.data?.targetBranch?.id ||
|
||||
a.destination?.data?.targetBranch?.id -
|
||||
b.destination?.data?.targetBranch?.id ||
|
||||
a.product?.name.localeCompare(b.product?.name),
|
||||
);
|
||||
|
||||
@@ -105,9 +124,19 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
grouped.push(group);
|
||||
}
|
||||
|
||||
return [...grouped].sort((a, b) => (a?.orderType === undefined ? -1 : b?.orderType === undefined ? 1 : 0));
|
||||
return [...grouped].sort((a, b) =>
|
||||
a?.orderType === undefined
|
||||
? -1
|
||||
: b?.orderType === undefined
|
||||
? 1
|
||||
: 0,
|
||||
);
|
||||
},
|
||||
[] as { orderType: string; destination: DestinationDTO; items: ShoppingCartItemDTO[] }[],
|
||||
[] as {
|
||||
orderType: string;
|
||||
destination: DestinationDTO;
|
||||
items: ShoppingCartItemDTO[];
|
||||
}[],
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -138,7 +167,14 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
.getPromotionPoints({
|
||||
items,
|
||||
})
|
||||
.pipe(map((response) => Object.values(response.result).reduce((sum, points) => sum + points, 0)));
|
||||
.pipe(
|
||||
map((response) =>
|
||||
Object.values(response.result).reduce(
|
||||
(sum, points) => sum + points,
|
||||
0,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return NEVER;
|
||||
}
|
||||
@@ -147,20 +183,25 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
|
||||
customerFeatures$ = this._store.customerFeatures$;
|
||||
|
||||
checkNotificationChannelControl$ = this._store.checkNotificationChannelControl$;
|
||||
checkNotificationChannelControl$ =
|
||||
this._store.checkNotificationChannelControl$;
|
||||
|
||||
showQuantityControlSpinnerItemId: number;
|
||||
quantityError$ = new BehaviorSubject<{ [key: string]: string }>({});
|
||||
|
||||
primaryCtaLabel$ = combineLatest([this.payer$, this.buyer$, this.shoppingCartItemsWithoutOrderType$]).pipe(
|
||||
primaryCtaLabel$ = combineLatest([
|
||||
this.payer$,
|
||||
this.buyer$,
|
||||
this.shoppingCartItemsWithoutOrderType$,
|
||||
]).pipe(
|
||||
map(([payer, buyer, shoppingCartItemsWithoutOrderType]) => {
|
||||
if (shoppingCartItemsWithoutOrderType?.length > 0) {
|
||||
return 'Kaufoptionen';
|
||||
return "Kaufoptionen";
|
||||
}
|
||||
if (!(payer || buyer)) {
|
||||
return 'Weiter';
|
||||
return "Weiter";
|
||||
}
|
||||
return 'Bestellen';
|
||||
return "Bestellen";
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -181,12 +222,16 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
|
||||
checkoutIsInValid$ = this.applicationService.activatedProcessId$.pipe(
|
||||
takeUntil(this._onDestroy$),
|
||||
switchMap((processId) => this.domainCheckoutService.checkoutIsValid({ processId })),
|
||||
switchMap((processId) =>
|
||||
this.domainCheckoutService.checkoutIsValid({ processId }),
|
||||
),
|
||||
map((valid) => !valid),
|
||||
);
|
||||
|
||||
get productSearchBasePath() {
|
||||
return this._productNavigationService.getArticleSearchBasePath(this.applicationService.activatedProcessId).path;
|
||||
return this._productNavigationService.getArticleSearchBasePath(
|
||||
this.applicationService.activatedProcessId,
|
||||
).path;
|
||||
}
|
||||
|
||||
get isDesktop$() {
|
||||
@@ -219,14 +264,16 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.applicationService.activatedProcessId$.pipe(takeUntil(this._onDestroy$)).subscribe((_) => {
|
||||
this._store.loadShoppingCart();
|
||||
});
|
||||
this.applicationService.activatedProcessId$
|
||||
.pipe(takeUntil(this._onDestroy$))
|
||||
.subscribe((_) => {
|
||||
this._store.loadShoppingCart();
|
||||
});
|
||||
|
||||
await this.removeBreadcrumbs();
|
||||
await this.updateBreadcrumb();
|
||||
|
||||
window['Checkout'] = {
|
||||
window["Checkout"] = {
|
||||
refreshAvailabilities: this.refreshAvailabilities.bind(this),
|
||||
};
|
||||
}
|
||||
@@ -267,13 +314,16 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
group: { items: ShoppingCartItemDTO[] },
|
||||
i: number,
|
||||
) {
|
||||
return i === 0 ? false : targetBranch.id !== group.items[i - 1].destination?.data?.targetBranch?.data.id;
|
||||
return i === 0
|
||||
? false
|
||||
: targetBranch.id !==
|
||||
group.items[i - 1].destination?.data?.targetBranch?.data.id;
|
||||
}
|
||||
|
||||
async refreshAvailabilities() {
|
||||
this.checkingOla$.next(true);
|
||||
|
||||
for (let itemComp of this._shoppingCartItems.toArray()) {
|
||||
for (const itemComp of this._shoppingCartItems.toArray()) {
|
||||
await itemComp.refreshAvailability();
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
@@ -283,16 +333,22 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
async updateBreadcrumb() {
|
||||
await this.breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
||||
key: this.applicationService.activatedProcessId,
|
||||
name: 'Warenkorb',
|
||||
path: this._navigationService.getCheckoutReviewPath(this.applicationService.activatedProcessId).path,
|
||||
tags: ['checkout', 'cart'],
|
||||
section: 'customer',
|
||||
name: "Warenkorb",
|
||||
path: this._navigationService.getCheckoutReviewPath(
|
||||
this.applicationService.activatedProcessId,
|
||||
).path,
|
||||
tags: ["checkout", "cart"],
|
||||
section: "customer",
|
||||
});
|
||||
}
|
||||
|
||||
async removeBreadcrumbs() {
|
||||
const checkoutDummyCrumbs = await this.breadcrumb
|
||||
.getBreadcrumbsByKeyAndTags$(this.applicationService.activatedProcessId, ['checkout', 'cart', 'dummy'])
|
||||
.getBreadcrumbsByKeyAndTags$(this.applicationService.activatedProcessId, [
|
||||
"checkout",
|
||||
"cart",
|
||||
"dummy",
|
||||
])
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
checkoutDummyCrumbs.forEach(async (crumb) => {
|
||||
@@ -304,32 +360,49 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this._store.notificationsControl = undefined;
|
||||
}
|
||||
|
||||
openDummyModal({ data, changeDataFromCart = false }: { data?: CheckoutDummyData; changeDataFromCart?: boolean }) {
|
||||
openDummyModal({
|
||||
data,
|
||||
changeDataFromCart = false,
|
||||
}: {
|
||||
data?: CheckoutDummyData;
|
||||
changeDataFromCart?: boolean;
|
||||
}) {
|
||||
this.uiModal.open({
|
||||
content: CheckoutDummyComponent,
|
||||
data: { ...data, changeDataFromCart },
|
||||
});
|
||||
}
|
||||
|
||||
changeDummyItem({ shoppingCartItem }: { shoppingCartItem: ShoppingCartItemDTO }) {
|
||||
changeDummyItem({
|
||||
shoppingCartItem,
|
||||
}: {
|
||||
shoppingCartItem: ShoppingCartItemDTO;
|
||||
}) {
|
||||
this.openDummyModal({ data: shoppingCartItem, changeDataFromCart: true });
|
||||
}
|
||||
|
||||
async changeItem({ shoppingCartItem }: { shoppingCartItem: ShoppingCartItemDTO }) {
|
||||
async changeItem({
|
||||
shoppingCartItem,
|
||||
}: {
|
||||
shoppingCartItem: ShoppingCartItemDTO;
|
||||
}) {
|
||||
this._purchaseOptionsModalService.open({
|
||||
processId: this.applicationService.activatedProcessId,
|
||||
items: [shoppingCartItem],
|
||||
type: 'update',
|
||||
type: "update",
|
||||
});
|
||||
}
|
||||
|
||||
async openPrintModal() {
|
||||
let shoppingCart = await this.shoppingCart$.pipe(first()).toPromise();
|
||||
const shoppingCart = await this.shoppingCart$.pipe(first()).toPromise();
|
||||
this.uiModal.open({
|
||||
content: PrintModalComponent,
|
||||
data: {
|
||||
printerType: 'Label',
|
||||
print: (printer) => this.domainPrinterService.printCart({ cartId: shoppingCart.id, printer }).toPromise(),
|
||||
printerType: "Label",
|
||||
print: (printer) =>
|
||||
this.domainPrinterService
|
||||
.printCart({ cartId: shoppingCart.id, printer })
|
||||
.toPromise(),
|
||||
} as PrintModalData,
|
||||
config: {
|
||||
panelClass: [],
|
||||
@@ -351,7 +424,8 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
|
||||
this.loadingOnQuantityChangeById$.next(shoppingCartItem.id);
|
||||
|
||||
const shoppingCartItemPrice = shoppingCartItem?.availability?.price?.value?.value;
|
||||
const shoppingCartItemPrice =
|
||||
shoppingCartItem?.availability?.price?.value?.value;
|
||||
const orderType = shoppingCartItem?.features?.orderType;
|
||||
let availability: AvailabilityDTO;
|
||||
|
||||
@@ -360,7 +434,7 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
|
||||
if (orderType) {
|
||||
switch (orderType) {
|
||||
case 'Rücklage':
|
||||
case "Rücklage":
|
||||
availability = await this.availabilityService
|
||||
.getTakeAwayAvailability({
|
||||
item: {
|
||||
@@ -369,12 +443,13 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
price: shoppingCartItem.availability.price,
|
||||
},
|
||||
quantity,
|
||||
branch,
|
||||
})
|
||||
.toPromise();
|
||||
|
||||
// this.setQuantityError(shoppingCartItem, availability, availability?.inStock < quantity);
|
||||
break;
|
||||
case 'Abholung':
|
||||
case "Abholung":
|
||||
availability = await this.availabilityService
|
||||
.getPickUpAvailability({
|
||||
branch,
|
||||
@@ -388,7 +463,7 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
.pipe(map((av) => av[0]))
|
||||
.toPromise();
|
||||
break;
|
||||
case 'Versand':
|
||||
case "Versand":
|
||||
availability = await this.availabilityService
|
||||
.getDeliveryAvailability({
|
||||
item: {
|
||||
@@ -400,7 +475,7 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
})
|
||||
.toPromise();
|
||||
break;
|
||||
case 'DIG-Versand':
|
||||
case "DIG-Versand":
|
||||
availability = await this.availabilityService
|
||||
.getDigDeliveryAvailability({
|
||||
item: {
|
||||
@@ -412,7 +487,7 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
})
|
||||
.toPromise();
|
||||
break;
|
||||
case 'B2B-Versand':
|
||||
case "B2B-Versand":
|
||||
availability = await this.availabilityService
|
||||
.getB2bDeliveryAvailability({
|
||||
item: {
|
||||
@@ -424,7 +499,7 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
})
|
||||
.toPromise();
|
||||
break;
|
||||
case 'Download':
|
||||
case "Download":
|
||||
availability = await this.availabilityService
|
||||
.getDownloadAvailability({
|
||||
item: {
|
||||
@@ -463,7 +538,11 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
shoppingCartItemId: shoppingCartItem.id,
|
||||
update: {
|
||||
quantity,
|
||||
availability: this.compareDeliveryAndCatalogPrice(updateAvailability, orderType, shoppingCartItemPrice),
|
||||
availability: this.compareDeliveryAndCatalogPrice(
|
||||
updateAvailability,
|
||||
orderType,
|
||||
shoppingCartItemPrice,
|
||||
),
|
||||
},
|
||||
})
|
||||
.toPromise();
|
||||
@@ -483,8 +562,15 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
}
|
||||
|
||||
// Bei unbekannten Kunden und DIG Bestellung findet ein Vergleich der Preise statt
|
||||
compareDeliveryAndCatalogPrice(availability: AvailabilityDTO, orderType: string, shoppingCartItemPrice: number) {
|
||||
if (['Versand', 'DIG-Versand'].includes(orderType) && shoppingCartItemPrice < availability?.price?.value?.value) {
|
||||
compareDeliveryAndCatalogPrice(
|
||||
availability: AvailabilityDTO,
|
||||
orderType: string,
|
||||
shoppingCartItemPrice: number,
|
||||
) {
|
||||
if (
|
||||
["Versand", "DIG-Versand"].includes(orderType) &&
|
||||
shoppingCartItemPrice < availability?.price?.value?.value
|
||||
) {
|
||||
return {
|
||||
...availability,
|
||||
price: {
|
||||
@@ -507,7 +593,10 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
.pipe(
|
||||
first(),
|
||||
switchMap((customerFeatures) => {
|
||||
return this.domainCheckoutService.canSetCustomer({ processId, customerFeatures });
|
||||
return this.domainCheckoutService.canSetCustomer({
|
||||
processId,
|
||||
customerFeatures,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.toPromise();
|
||||
@@ -524,24 +613,31 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this._purchaseOptionsModalService.open({
|
||||
processId: this.applicationService.activatedProcessId,
|
||||
items: shoppingCartItems,
|
||||
type: 'update',
|
||||
type: "update",
|
||||
});
|
||||
}
|
||||
|
||||
async changeAddress() {
|
||||
const processId = this.applicationService.activatedProcessId;
|
||||
const customer = await this.domainCheckoutService.getBuyer({ processId }).pipe(first()).toPromise();
|
||||
const customer = await this.domainCheckoutService
|
||||
.getBuyer({ processId })
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
if (!customer) {
|
||||
this.navigateToCustomerSearch(processId);
|
||||
return;
|
||||
}
|
||||
const customerId = customer.source;
|
||||
const nav = this._customerSearchNavigation.detailsRoute({ processId, customerId });
|
||||
const nav = this._customerSearchNavigation.detailsRoute({
|
||||
processId,
|
||||
customerId,
|
||||
});
|
||||
this.router.navigate(nav.path);
|
||||
}
|
||||
|
||||
async order() {
|
||||
const shoppingCartItemsWithoutOrderType = await this.shoppingCartItemsWithoutOrderType$.pipe(first()).toPromise();
|
||||
const shoppingCartItemsWithoutOrderType =
|
||||
await this.shoppingCartItemsWithoutOrderType$.pipe(first()).toPromise();
|
||||
|
||||
if (shoppingCartItemsWithoutOrderType?.length > 0) {
|
||||
this.showPurchasingListModal(shoppingCartItemsWithoutOrderType);
|
||||
@@ -549,7 +645,10 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
}
|
||||
|
||||
const processId = this.applicationService.activatedProcessId;
|
||||
const customer = await this.domainCheckoutService.getBuyer({ processId }).pipe(first()).toPromise();
|
||||
const customer = await this.domainCheckoutService
|
||||
.getBuyer({ processId })
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
if (!customer) {
|
||||
this.navigateToCustomerSearch(processId);
|
||||
} else {
|
||||
@@ -557,33 +656,42 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
this.showOrderButtonSpinner = true;
|
||||
// Ticket #3287 Um nur E-Mail und SMS Benachrichtigungen zu setzen und um alle anderen Benachrichtigungskanäle wie z.B. Brief zu deaktivieren
|
||||
await this._store.onNotificationChange();
|
||||
const orders = await this.domainCheckoutService.completeCheckout({ processId }).toPromise();
|
||||
const orderIds = orders.map((order) => order.id).join(',');
|
||||
const orders = await this.domainCheckoutService
|
||||
.completeCheckout({ processId })
|
||||
.toPromise();
|
||||
const orderIds = orders.map((order) => order.id).join(",");
|
||||
this._store.orderCompleted.next();
|
||||
await this.patchProcess(processId);
|
||||
await this._navigationService.getCheckoutSummaryPath({ processId, orderIds }).navigate();
|
||||
await this._navigationService
|
||||
.getCheckoutSummaryPath({ processId, orderIds })
|
||||
.navigate();
|
||||
} catch (error) {
|
||||
const response = error?.error;
|
||||
let message: string = response?.message ?? '';
|
||||
let message: string = response?.message ?? "";
|
||||
|
||||
if (response?.invalidProperties && Object.values(response?.invalidProperties)?.length) {
|
||||
message += `\n${Object.values(response.invalidProperties).join('\n')}`;
|
||||
if (
|
||||
response?.invalidProperties &&
|
||||
Object.values(response?.invalidProperties)?.length
|
||||
) {
|
||||
message += `\n${Object.values(response.invalidProperties).join("\n")}`;
|
||||
}
|
||||
|
||||
if (message?.length) {
|
||||
this.uiModal.open({
|
||||
content: UiMessageModalComponent,
|
||||
title: 'Hinweis',
|
||||
title: "Hinweis",
|
||||
data: { message: message.trim() },
|
||||
});
|
||||
} else if (error) {
|
||||
this.uiModal.error('Fehler beim abschließen der Bestellung', error);
|
||||
this.uiModal.error("Fehler beim abschließen der Bestellung", error);
|
||||
}
|
||||
|
||||
if (error.status === 409) {
|
||||
this._store.orderCompleted.next();
|
||||
await this.patchProcess(processId);
|
||||
await this._navigationService.getCheckoutSummaryPath({ processId }).navigate();
|
||||
await this._navigationService
|
||||
.getCheckoutSummaryPath({ processId })
|
||||
.navigate();
|
||||
}
|
||||
} finally {
|
||||
this.showOrderButtonSpinner = false;
|
||||
@@ -593,11 +701,14 @@ export class CheckoutReviewComponent implements OnInit, OnDestroy, AfterViewInit
|
||||
}
|
||||
|
||||
async patchProcess(processId: number) {
|
||||
const process = await this.applicationService.getProcessById$(processId).pipe(first()).toPromise();
|
||||
const process = await this.applicationService
|
||||
.getProcessById$(processId)
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
if (process) {
|
||||
this.applicationService.patchProcess(process.id, {
|
||||
name: `${process.name} Bestellbestätigung`,
|
||||
type: 'cart-checkout',
|
||||
type: "cart-checkout",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user