tripstorekrabi-shared 1.26.0 → 1.26.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.
- package/package.json +3 -3
- package/product.js +42 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tripstorekrabi-shared",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.1",
|
|
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,50 @@ 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 unified keywords array (falls back to legacy tags if keywords has no valid entries)
|
|
96
|
+
const validKeywords = Array.isArray(product.keywords)
|
|
97
|
+
? product.keywords.map((k) => String(k || '').trim()).filter(Boolean)
|
|
98
|
+
: [];
|
|
99
|
+
|
|
100
|
+
const validTags = Array.isArray(product.tags)
|
|
101
|
+
? product.tags.map((t) => String(t || '').trim()).filter(Boolean)
|
|
102
|
+
: [];
|
|
103
|
+
|
|
104
|
+
document.keywords = Array.from(new Set(validKeywords.length > 0 ? validKeywords : validTags));
|
|
105
|
+
|
|
106
|
+
// TODO stef Keep legacy tags synced for backward compatibility until tags is fully removed from frontend
|
|
107
|
+
document.tags = validTags.length > 0 ? Array.from(new Set(validTags)) : document.keywords;
|
|
108
|
+
|
|
109
|
+
if (isTransfer) {
|
|
110
|
+
document.from = String(product.from).trim();
|
|
111
|
+
document.to = String(product.to).trim();
|
|
83
112
|
|
|
84
113
|
if (Array.isArray(product.waypoints) && product.waypoints.length > 0) {
|
|
85
114
|
const startWp = product.waypoints[0]?.latLng;
|