From de3edaa0f95fbf2078fe731f380f406e2864d57f Mon Sep 17 00:00:00 2001 From: Nino Righi Date: Wed, 10 Dec 2025 17:12:47 +0000 Subject: [PATCH] Merged PR 2077: fix(checkout-data-access, checkout-reward-shopping-cart, checkout-reward-sele... fix(checkout-data-access, checkout-reward-shopping-cart, checkout-reward-selection-dialog): Show Low Stock message inside Dialog, Adjusted Item Identifyer so that mergedItems inside reward-selection-dialog service works properly, Adjusted Error Message Logic and Quantity Select Logic based on purchasing Options for Abholung Ref: #5523 --- .../get-shopping-cart-item-key.helper.ts | 7 +++-- ...ng-cart-item-quantity-control.component.ts | 3 +- .../reward-shopping-cart-item.component.html | 23 +++++++++----- .../reward-shopping-cart-item.component.ts | 10 +++++++ .../reward-selection-error.component.css | 2 +- .../reward-selection-error.component.html | 14 +++++---- .../reward-selection-inputs.component.ts | 5 +--- .../reward-selection-item.component.html | 13 ++++++++ .../reward-selection-item.component.ts | 30 +++++++++++++++++-- 9 files changed, 83 insertions(+), 24 deletions(-) diff --git a/libs/checkout/data-access/src/lib/helpers/get-shopping-cart-item-key.helper.ts b/libs/checkout/data-access/src/lib/helpers/get-shopping-cart-item-key.helper.ts index d35a8cb8e..dccdb5038 100644 --- a/libs/checkout/data-access/src/lib/helpers/get-shopping-cart-item-key.helper.ts +++ b/libs/checkout/data-access/src/lib/helpers/get-shopping-cart-item-key.helper.ts @@ -4,12 +4,13 @@ import { } from '@isa/checkout/data-access'; /** - * Creates a unique key for an item based on EAN, destination, and orderItemType. + * Creates a unique key for an item based on EAN, targetBranchId, and orderItemType. * Items are only considered identical if all three match. */ export const getItemKey = (item: ShoppingCartItem): string => { const ean = item.product.ean ?? 'no-ean'; - const destinationId = item.destination?.data?.id ?? 'no-destination'; + const targetBranchId = + item.destination?.data?.targetBranch?.id ?? 'no-target-branch-id'; const orderType = getOrderTypeFeature(item.features) ?? 'no-orderType'; - return `${ean}|${destinationId}|${orderType}`; + return `${ean}|${targetBranchId}|${orderType}`; }; diff --git a/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item-quantity-control.component.ts b/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item-quantity-control.component.ts index 16dbf523c..deb05128a 100644 --- a/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item-quantity-control.component.ts +++ b/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item-quantity-control.component.ts @@ -66,7 +66,8 @@ export class RewardShoppingCartItemQuantityControlComponent { if ( orderType === OrderTypeFeature.Delivery || orderType === OrderTypeFeature.DigitalShipping || - orderType === OrderTypeFeature.B2BShipping + orderType === OrderTypeFeature.B2BShipping || + orderType === OrderTypeFeature.Pickup ) { return 999; } diff --git a/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.html b/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.html index 863f822ac..c7f6bf2f3 100644 --- a/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.html +++ b/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.html @@ -37,11 +37,20 @@ -@if (quantityControl.maxQuantity() < 2 && !isDownload()) { -
- -
Geringer Bestand - Artikel holen vor Abschluss
-
+@if (!isDownload()) { + @if (showLowStockMessage()) { +
+ +
{{ inStock() }} Exemplare sofort lieferbar
+
+ } @else if (quantityControl.maxQuantity() < 2) { +
+ +
Geringer Bestand - Artikel holen vor Abschluss
+
+ } } diff --git a/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.ts b/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.ts index 7f2b1ec42..2b9881f5d 100644 --- a/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.ts +++ b/libs/checkout/feature/reward-shopping-cart/src/lib/reward-shopping-cart-item/reward-shopping-cart-item.component.ts @@ -72,6 +72,16 @@ export class RewardShoppingCartItemComponent { hasOrderTypeFeature(this.item().features, ['Download']), ); + isAbholung = computed(() => + hasOrderTypeFeature(this.item().features, ['Abholung']), + ); + + inStock = computed(() => this.item().availability?.inStock ?? 0); + + showLowStockMessage = computed(() => { + return this.isAbholung() && this.inStock() < 2; + }); + async updatePurchaseOption() { const shoppingCartItemId = this.itemId(); const shoppingCartId = this.shoppingCartId(); diff --git a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.css b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.css index 4fe16d287..f7d6a9448 100644 --- a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.css +++ b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.css @@ -1,3 +1,3 @@ :host { - @apply text-isa-accent-red isa-text-body-2-bold flex flex-row gap-2 items-center; + @apply text-isa-accent-red isa-text-body-2-bold flex flex-col gap-2 items-start; } diff --git a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.html b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.html index 201f2e798..cf478c74a 100644 --- a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.html +++ b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-error/reward-selection-error.component.html @@ -1,8 +1,10 @@ @if (store.totalLoyaltyPointsNeeded() > store.customerRewardPoints()) { - - Lesepunkte reichen nicht für alle Artikel +
+ + Lesepunkte reichen nicht für alle Artikel +
} diff --git a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-inputs/reward-selection-inputs.component.ts b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-inputs/reward-selection-inputs.component.ts index e07188558..43addd9a5 100644 --- a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-inputs/reward-selection-inputs.component.ts +++ b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-inputs/reward-selection-inputs.component.ts @@ -41,10 +41,7 @@ export class RewardSelectionInputsComponent { hasCorrectOrderType = computed(() => { const item = this.rewardSelectionItem().item; - return hasOrderTypeFeature(item.features, [ - OrderTypeFeature.InStore, - OrderTypeFeature.Pickup, - ]); + return hasOrderTypeFeature(item.features, [OrderTypeFeature.InStore]); }); hasStock = computed(() => { diff --git a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.html b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.html index e80c67070..9d548e856 100644 --- a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.html +++ b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.html @@ -27,3 +27,16 @@ + +@if (showLowStockMessage()) { +
+ + {{ inStock() }} Exemplare sofort lieferbar +
+} diff --git a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.ts b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.ts index da5891cdf..6ecda39ec 100644 --- a/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.ts +++ b/libs/checkout/shared/reward-selection-dialog/src/lib/reward-selection-dialog/reward-selection-items/reward-selection-item/reward-selection-item.component.ts @@ -1,8 +1,18 @@ -import { ChangeDetectionStrategy, Component, input } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + computed, + input, +} from '@angular/core'; import { ProductImageDirective } from '@isa/shared/product-image'; import { ProductRouterLinkDirective } from '@isa/shared/product-router-link'; import { RewardSelectionInputsComponent } from './reward-selection-inputs/reward-selection-inputs.component'; -import { RewardSelectionItem } from '@isa/checkout/data-access'; +import { + hasOrderTypeFeature, + RewardSelectionItem, +} from '@isa/checkout/data-access'; +import { NgIcon, provideIcons } from '@ng-icons/core'; +import { isaOtherInfo } from '@isa/icons'; @Component({ selector: 'lib-reward-selection-item', @@ -13,8 +23,24 @@ import { RewardSelectionItem } from '@isa/checkout/data-access'; ProductImageDirective, ProductRouterLinkDirective, RewardSelectionInputsComponent, + NgIcon, ], + providers: [provideIcons({ isaOtherInfo })], }) export class RewardSelectionItemComponent { rewardSelectionItem = input.required(); + + inStock = computed( + () => this.rewardSelectionItem().item?.availability?.inStock ?? 0, + ); + + isAbholung = computed(() => + hasOrderTypeFeature(this.rewardSelectionItem()?.item?.features, [ + 'Abholung', + ]), + ); + + showLowStockMessage = computed(() => { + return this.isAbholung() && this.inStock() < 2; + }); }