tripstorekrabi-shared 1.11.4 → 1.11.5

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 +1 -1
  2. package/package.json +3 -2
  3. package/product.js +33 -0
package/booking.js CHANGED
@@ -211,7 +211,7 @@ export function buildIndex(id, booking) {
211
211
  }
212
212
  phoneNumbers = [...new Set(phoneNumbers)];
213
213
 
214
- return { id, referenceNumbers, travellers, emails, pickupHotel, phoneNumbers }
214
+ return { id, referenceNumbers, travellers, emails, pickupHotel, phoneNumbers };
215
215
  }
216
216
 
217
217
  function addPhoneNumbers(phoneNumbers, phoneNumber) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.11.4",
3
+ "version": "1.11.5",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
@@ -11,7 +11,8 @@
11
11
  "./utils": "./utils.js",
12
12
  "./price": "./price.js",
13
13
  "./availability": "./availability.js",
14
- "./booking": "./booking.js"
14
+ "./booking": "./booking.js",
15
+ "./product": "./product.js"
15
16
  },
16
17
  "dependencies": {
17
18
  "dayjs": "^1.11.7"
package/product.js ADDED
@@ -0,0 +1,33 @@
1
+ export function buildIndex(id, product) {
2
+ let document = {
3
+ id,
4
+ title: product.title,
5
+ subtitle: product.subtitle,
6
+ summary: product.summary,
7
+ description: product.description.map((item) => stripHTML(item)).join(" "),
8
+ heroPhoto: product.heroPhoto,
9
+ operator: [product.operator.default.name],
10
+ url: product.url,
11
+ price: calculateProductPrice({ adults: countMinPeople(product.pricing), children: 0, infants: 0 }, product.pricing) / countMinPeople(product.pricing),
12
+ priceType: product.pricing.type,
13
+ availability: product.availability
14
+ };
15
+
16
+ if (product.destinations) {
17
+ document.destinations = product.destinations;
18
+ }
19
+ if (product.tags) {
20
+ document.tags = product.tags;
21
+ }
22
+
23
+ if (product.from && product.to) {
24
+ document.from = product.from;
25
+ document.to = product.to
26
+ document.start = [product.waypoints[0].latLng.lat, product.waypoints[0].latLng.lng];
27
+ document.end = [product.waypoints[product.waypoints.length - 1].latLng.lat, product.waypoints[product.waypoints.length - 1].latLng.lng];
28
+ }
29
+
30
+ document.type = product.from ? "transfer" : "activity";
31
+
32
+ return document;
33
+ }