mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
#3984 - Filtereinstellungen wenn Artikel für Dig-Versand in Warenkorb sind falsch
This commit is contained in:
@@ -178,14 +178,16 @@ export function getItemsForList(state: PurchaseOptionsState): Item[] {
|
||||
return items.filter((item) => itemIds.includes(item.id));
|
||||
}
|
||||
|
||||
export function getAvailabilitiesForItem(itemId: number): (state: PurchaseOptionsState) => Availability[] {
|
||||
export function getAvailabilitiesForItem(
|
||||
itemId: number,
|
||||
allDeliveryAvailabilities?: boolean
|
||||
): (state: PurchaseOptionsState) => Availability[] {
|
||||
return (state) => {
|
||||
let availabilities = getAvailabilities(state);
|
||||
availabilities = availabilities.filter((availability) => availability.itemId === itemId);
|
||||
|
||||
// if 'delivery', 'dig-delivery' and 'b2b-delivery' are present remove 'dig-delivery' and 'b2b-delivery'
|
||||
|
||||
if (availabilities.some((availability) => availability.purchaseOption === 'delivery')) {
|
||||
if (!allDeliveryAvailabilities && availabilities.some((availability) => availability.purchaseOption === 'delivery')) {
|
||||
availabilities = availabilities.filter(
|
||||
(availability) => availability.purchaseOption !== 'dig-delivery' && availability.purchaseOption !== 'b2b-delivery'
|
||||
);
|
||||
@@ -280,17 +282,17 @@ export function getAvailabilityWithPurchaseOption(
|
||||
purchaseOption: PurchaseOption
|
||||
): (state: PurchaseOptionsState) => Availability {
|
||||
return (state) => {
|
||||
let availabilities = getAvailabilitiesForItem(itemId)(state);
|
||||
let availabilities = getAvailabilitiesForItem(itemId, true)(state);
|
||||
|
||||
let availability = availabilities.find((availability) => availability.purchaseOption === purchaseOption);
|
||||
|
||||
if (purchaseOption === 'delivery') {
|
||||
const digAvailability = availabilities.find((availability) => availability.purchaseOption === 'dig-delivery');
|
||||
const b2bAvailability = availabilities.find((availability) => availability.purchaseOption === 'b2b-delivery');
|
||||
|
||||
availability = availability || digAvailability || b2bAvailability;
|
||||
if (!(digAvailability && b2bAvailability)) {
|
||||
availability = digAvailability ?? b2bAvailability;
|
||||
}
|
||||
}
|
||||
|
||||
return availability;
|
||||
};
|
||||
}
|
||||
@@ -327,7 +329,6 @@ export function canContinue(state: PurchaseOptionsState): boolean {
|
||||
if (isGiftCard(item, getType(state))) {
|
||||
const price = getPriceForPurchaseOption(item.id, purchaseOption)(state);
|
||||
if (!(price?.value?.value > 0 && price?.value?.value <= GIFT_CARD_MAX_PRICE)) {
|
||||
console.log('price', price);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user