tripstorekrabi-shared 1.23.1 → 1.23.2
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 +15 -8
- package/package.json +1 -1
package/booking.js
CHANGED
|
@@ -370,7 +370,7 @@ export function requiresDietaryInfo(booking, product) {
|
|
|
370
370
|
const foodAddOnsInBooking =
|
|
371
371
|
booking?.addOns?.filter((bAddOn) => {
|
|
372
372
|
const productAddOn = product.addOns?.find((pAddOn) => pAddOn.id === bAddOn.id);
|
|
373
|
-
return productAddOn && hasFood(productAddOn);
|
|
373
|
+
return productAddOn && hasFood(productAddOn.title);
|
|
374
374
|
}) || [];
|
|
375
375
|
|
|
376
376
|
const hasFoodAddOnWithPax = foodAddOnsInBooking.some((bAddOn) => {
|
|
@@ -384,14 +384,21 @@ export function requiresDietaryInfo(booking, product) {
|
|
|
384
384
|
return mainIsFood;
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
export function hasFood(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
export function hasFood(input) {
|
|
388
|
+
if (!input) return false;
|
|
389
|
+
|
|
390
|
+
const items = [input].flat().map(item => {
|
|
391
|
+
if (typeof item === 'string') return item;
|
|
392
|
+
return item?.title || item?.name || '';
|
|
393
|
+
});
|
|
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) {
|