tripstorekrabi-shared 1.26.3 → 1.26.4
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 +1 -1
- package/product.js +11 -33
package/package.json
CHANGED
package/product.js
CHANGED
|
@@ -40,8 +40,12 @@ export function buildIndex(id, product) {
|
|
|
40
40
|
|
|
41
41
|
const safeIntPrice = isNaN(rawPrice) || !isFinite(rawPrice) ? 0 : Math.round(rawPrice);
|
|
42
42
|
|
|
43
|
+
const type = String(product.type || '').trim().toLowerCase() || (product.from ? 'transfer' : 'activity');
|
|
44
|
+
const isTransfer = type === 'transfer';
|
|
45
|
+
|
|
43
46
|
let document = {
|
|
44
47
|
id,
|
|
48
|
+
type,
|
|
45
49
|
title: String(product.title || '').trim(),
|
|
46
50
|
subtitle: String(product.subtitle || '').trim(),
|
|
47
51
|
summary: String(product.summary || '').trim(),
|
|
@@ -65,35 +69,6 @@ export function buildIndex(id, product) {
|
|
|
65
69
|
document.shortName = String(product.shortName).trim();
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
const isTransfer = Boolean(product.from && product.to);
|
|
69
|
-
|
|
70
|
-
if (isTransfer) {
|
|
71
|
-
// For transfers, 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
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
// 1. Assign new `places` array directly
|
|
80
|
-
if (Array.isArray(product.places) && product.places.length > 0) {
|
|
81
|
-
document.places = product.places;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// 2. Keep legacy `destinations` array populated during transition
|
|
85
|
-
const rawDestinations = Array.isArray(product.destinations) ? product.destinations : [];
|
|
86
|
-
|
|
87
|
-
const cleanedDestinations = Array.from(
|
|
88
|
-
new Set(rawDestinations.map((d) => String(d || '').trim()).filter(Boolean))
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
if (cleanedDestinations.length > 0) {
|
|
92
|
-
document.destinations = cleanedDestinations;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Populate keywords array
|
|
97
72
|
const validKeywords = Array.isArray(product.keywords)
|
|
98
73
|
? product.keywords.map((k) => String(k || '').trim()).filter(Boolean)
|
|
99
74
|
: [];
|
|
@@ -101,8 +76,11 @@ export function buildIndex(id, product) {
|
|
|
101
76
|
document.keywords = Array.from(new Set(validKeywords));
|
|
102
77
|
|
|
103
78
|
if (isTransfer) {
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
const from = String(product.from || '').trim();
|
|
80
|
+
const to = String(product.to || '').trim();
|
|
81
|
+
|
|
82
|
+
if (from) document.from = from;
|
|
83
|
+
if (to) document.to = to;
|
|
106
84
|
|
|
107
85
|
if (Array.isArray(product.waypoints) && product.waypoints.length > 0) {
|
|
108
86
|
const startWp = product.waypoints[0]?.latLng;
|
|
@@ -115,9 +93,9 @@ export function buildIndex(id, product) {
|
|
|
115
93
|
document.end = [endWp.lat, endWp.lng];
|
|
116
94
|
}
|
|
117
95
|
}
|
|
96
|
+
} else if (Array.isArray(product.places) && product.places.length > 0) {
|
|
97
|
+
document.places = product.places;
|
|
118
98
|
}
|
|
119
99
|
|
|
120
|
-
document.type = product.from ? 'transfer' : 'activity';
|
|
121
|
-
|
|
122
100
|
return document;
|
|
123
101
|
}
|