tripstorekrabi-shared 1.23.1 → 1.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/booking.js +25 -18
- package/package.json +1 -1
package/booking.js
CHANGED
|
@@ -367,31 +367,38 @@ export function requiresDietaryInfo(booking, product) {
|
|
|
367
367
|
|
|
368
368
|
const mainIsFood = hasFood(product);
|
|
369
369
|
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const hasFoodAddOnWithPax = foodAddOnsInBooking.some((bAddOn) => {
|
|
377
|
-
return (bAddOn.adults || 0) + (bAddOn.children || 0) > 0;
|
|
378
|
-
});
|
|
370
|
+
const productFoodAddOns = (product.addOns || []).filter(pAddOn => hasFood(pAddOn));
|
|
371
|
+
|
|
372
|
+
if (productFoodAddOns.length > 0) {
|
|
373
|
+
const hasActiveFoodAddOn = productFoodAddOns.some(pAddOn => {
|
|
374
|
+
const bookedAddOn = booking?.addOns?.find(bAddOn => bAddOn.id === pAddOn.id);
|
|
375
|
+
if (!bookedAddOn) return false;
|
|
379
376
|
|
|
380
|
-
|
|
381
|
-
|
|
377
|
+
const totalPax = (bookedAddOn.adults || 0) + (bookedAddOn.children || 0);
|
|
378
|
+
return totalPax > 0;
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
return hasActiveFoodAddOn;
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
return mainIsFood;
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
export function hasFood(
|
|
388
|
-
|
|
389
|
-
item = item.toLowerCase();
|
|
390
|
-
return item.includes('breakfast') || item.includes('lunch') || item.includes('brunch') || item.includes('dinner') || item.includes('snacks');
|
|
391
|
-
}) != null;
|
|
392
|
-
}
|
|
387
|
+
export function hasFood(input) {
|
|
388
|
+
if (!input) return false;
|
|
393
389
|
|
|
390
|
+
const items = [input].flat().map(item => {
|
|
391
|
+
if (typeof item === 'string') return item;
|
|
392
|
+
return item?.title || item?.name || '';
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const foodKeywords = ['breakfast', 'lunch', 'brunch', 'dinner', 'snacks'];
|
|
394
396
|
|
|
397
|
+
return items.some(item => {
|
|
398
|
+
const lowerItem = item.toLowerCase();
|
|
399
|
+
return foodKeywords.some(keyword => lowerItem.includes(keyword));
|
|
400
|
+
});
|
|
401
|
+
}
|
|
395
402
|
|
|
396
403
|
export function createTodos(booking, product) {
|
|
397
404
|
let todos = {};
|
|
@@ -432,7 +439,7 @@ export function createTodos(booking, product) {
|
|
|
432
439
|
}
|
|
433
440
|
}
|
|
434
441
|
|
|
435
|
-
if (product &&
|
|
442
|
+
if (product && requiresDietaryInfo(booking, product)) {
|
|
436
443
|
if (!booking.dietary) {
|
|
437
444
|
todos.dietary = "missing";
|
|
438
445
|
} else if (!booking.dietaryConfirmed && booking.dietary?.length > 0 && booking.dietary !== 'None' && booking.sentToOperator === true) {
|