tripstorekrabi-shared 1.22.9 → 1.23.1

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.
Files changed (3) hide show
  1. package/booking.js +24 -0
  2. package/package.json +2 -2
  3. package/utils.js +1 -0
package/booking.js CHANGED
@@ -362,6 +362,28 @@ export function getStartingPointMessage(booking, product, options = { compact: f
362
362
  return text;
363
363
  }
364
364
 
365
+ export function requiresDietaryInfo(booking, product) {
366
+ if (!product) return true;
367
+
368
+ const mainIsFood = hasFood(product);
369
+
370
+ const foodAddOnsInBooking =
371
+ booking?.addOns?.filter((bAddOn) => {
372
+ const productAddOn = product.addOns?.find((pAddOn) => pAddOn.id === bAddOn.id);
373
+ return productAddOn && hasFood(productAddOn);
374
+ }) || [];
375
+
376
+ const hasFoodAddOnWithPax = foodAddOnsInBooking.some((bAddOn) => {
377
+ return (bAddOn.adults || 0) + (bAddOn.children || 0) > 0;
378
+ });
379
+
380
+ if (foodAddOnsInBooking.length > 0) {
381
+ return hasFoodAddOnWithPax;
382
+ }
383
+
384
+ return mainIsFood;
385
+ }
386
+
365
387
  export function hasFood(product) {
366
388
  return (product.includes ?? []).find((item) => {
367
389
  item = item.toLowerCase();
@@ -369,6 +391,8 @@ export function hasFood(product) {
369
391
  }) != null;
370
392
  }
371
393
 
394
+
395
+
372
396
  export function createTodos(booking, product) {
373
397
  let todos = {};
374
398
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.22.9",
3
+ "version": "1.23.1",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "dayjs": "^1.11.19",
21
- "libphonenumber-js": "^1.12.33",
21
+ "libphonenumber-js": "^1.12.36",
22
22
  "nanoid": "^5.1.6"
23
23
  },
24
24
  "scripts": {
package/utils.js CHANGED
@@ -78,6 +78,7 @@ export function formatNumber(number, fraction = 2) {
78
78
  return number.toLocaleString('th-TH', {
79
79
  minimumFractionDigits: fraction,
80
80
  maximumFractionDigits: fraction,
81
+ useGrouping: true,
81
82
  });
82
83
  }
83
84