tripstorekrabi-shared 1.11.4 → 1.11.6
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 +1 -1
- package/package.json +3 -2
- package/product.js +39 -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.
|
|
3
|
+
"version": "1.11.6",
|
|
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,39 @@
|
|
|
1
|
+
import { calculateProductPrice, countMinPeople } from "./price.js";
|
|
2
|
+
|
|
3
|
+
export function buildIndex(id, product) {
|
|
4
|
+
let document = {
|
|
5
|
+
id,
|
|
6
|
+
title: product.title,
|
|
7
|
+
subtitle: product.subtitle,
|
|
8
|
+
summary: product.summary,
|
|
9
|
+
description: product.description.map((item) => stripHTML(item)).join(" "),
|
|
10
|
+
heroPhoto: product.heroPhoto,
|
|
11
|
+
operator: [product.operator.default.name],
|
|
12
|
+
url: product.url,
|
|
13
|
+
price: calculateProductPrice({ adults: countMinPeople(product.pricing), children: 0, infants: 0 }, product.pricing) / countMinPeople(product.pricing),
|
|
14
|
+
priceType: product.pricing.type,
|
|
15
|
+
availability: product.availability
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
if (product.destinations) {
|
|
19
|
+
document.destinations = product.destinations;
|
|
20
|
+
}
|
|
21
|
+
if (product.tags) {
|
|
22
|
+
document.tags = product.tags;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (product.from && product.to) {
|
|
26
|
+
document.from = product.from;
|
|
27
|
+
document.to = product.to
|
|
28
|
+
document.start = [product.waypoints[0].latLng.lat, product.waypoints[0].latLng.lng];
|
|
29
|
+
document.end = [product.waypoints[product.waypoints.length - 1].latLng.lat, product.waypoints[product.waypoints.length - 1].latLng.lng];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
document.type = product.from ? "transfer" : "activity";
|
|
33
|
+
|
|
34
|
+
return document;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function stripHTML(html) {
|
|
38
|
+
return html.replace(MATCH_HTML_REGEXP, "");
|
|
39
|
+
}
|