tripstorekrabi-shared 1.26.0 → 1.26.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/package.json +3 -3
- package/product.js +35 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tripstorekrabi-shared",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.2",
|
|
4
4
|
"description": "Shared library for Trip Store Krabi",
|
|
5
5
|
"author": "Stefan Sommer <tonprince@gmail.com>",
|
|
6
6
|
"repository": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"dayjs": "^1.11.23",
|
|
21
|
-
"libphonenumber-js": "^1.13.
|
|
22
|
-
"nanoid": "^6.0.
|
|
21
|
+
"libphonenumber-js": "^1.13.15",
|
|
22
|
+
"nanoid": "^6.0.2",
|
|
23
23
|
"firebase-admin": "^14.5.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
package/product.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { calculateProductSellingPrice, countMinPeople } from
|
|
1
|
+
import { calculateProductSellingPrice, countMinPeople } from './price.js';
|
|
2
2
|
|
|
3
|
-
const MATCH_HTML_REGEXP = /(<([^>]+)>)/
|
|
3
|
+
const MATCH_HTML_REGEXP = /(<([^>]+)>)/gi;
|
|
4
4
|
|
|
5
5
|
function toIsoDateString(val) {
|
|
6
6
|
if (!val) return null;
|
|
@@ -65,21 +65,43 @@ export function buildIndex(id, product) {
|
|
|
65
65
|
document.shortName = String(product.shortName).trim();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
document.destinations = product.destinations;
|
|
70
|
-
} else if (product.destination) {
|
|
71
|
-
document.destinations = [product.destination];
|
|
72
|
-
}
|
|
68
|
+
const isTransfer = Boolean(product.from && product.to);
|
|
73
69
|
|
|
74
|
-
if (
|
|
75
|
-
|
|
70
|
+
if (isTransfer) {
|
|
71
|
+
// For transfers, always derive destinations directly from `from` and `to`
|
|
72
|
+
const transferDestinations = Array.from(
|
|
73
|
+
new Set([product.from, product.to].map((d) => String(d || '').trim()).filter(Boolean))
|
|
74
|
+
);
|
|
75
|
+
if (transferDestinations.length > 0) {
|
|
76
|
+
document.destinations = transferDestinations;
|
|
77
|
+
}
|
|
76
78
|
} else {
|
|
77
|
-
|
|
79
|
+
// For activities, clean and deduplicate `destinations` (or fallback to `destination`)
|
|
80
|
+
const rawDestinations = Array.isArray(product.destinations)
|
|
81
|
+
? product.destinations
|
|
82
|
+
: product.destination
|
|
83
|
+
? [product.destination]
|
|
84
|
+
: [];
|
|
85
|
+
|
|
86
|
+
const cleanedDestinations = Array.from(
|
|
87
|
+
new Set(rawDestinations.map((d) => String(d || '').trim()).filter(Boolean))
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (cleanedDestinations.length > 0) {
|
|
91
|
+
document.destinations = cleanedDestinations;
|
|
92
|
+
}
|
|
78
93
|
}
|
|
79
94
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
// Populate keywords array
|
|
96
|
+
const validKeywords = Array.isArray(product.keywords)
|
|
97
|
+
? product.keywords.map((k) => String(k || '').trim()).filter(Boolean)
|
|
98
|
+
: [];
|
|
99
|
+
|
|
100
|
+
document.keywords = Array.from(new Set(validKeywords));
|
|
101
|
+
|
|
102
|
+
if (isTransfer) {
|
|
103
|
+
document.from = String(product.from).trim();
|
|
104
|
+
document.to = String(product.to).trim();
|
|
83
105
|
|
|
84
106
|
if (Array.isArray(product.waypoints) && product.waypoints.length > 0) {
|
|
85
107
|
const startWp = product.waypoints[0]?.latLng;
|