tripstorekrabi-shared 1.26.4 → 1.26.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.
- package/package.json +1 -1
- package/product.js +50 -0
- package/utils.js +0 -2
package/package.json
CHANGED
package/product.js
CHANGED
|
@@ -2,6 +2,33 @@ import { calculateProductSellingPrice, countMinPeople } from './price.js';
|
|
|
2
2
|
|
|
3
3
|
const MATCH_HTML_REGEXP = /(<([^>]+)>)/gi;
|
|
4
4
|
|
|
5
|
+
export const GUIDANCE_TYPES = [
|
|
6
|
+
'Live Tour Guide',
|
|
7
|
+
'Instructor',
|
|
8
|
+
'Boat Crew / Staff',
|
|
9
|
+
'Driver Only',
|
|
10
|
+
'Audio Guide',
|
|
11
|
+
'No Guide / Self-Guided'
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export const UNGUIDED_TYPES = ['No Guide / Self-Guided', 'Driver Only'];
|
|
15
|
+
|
|
16
|
+
export const DEFAULT_GUIDE_LANGUAGES = new Set(['english', 'thai']);
|
|
17
|
+
|
|
18
|
+
export const GUIDE_LANGUAGES = [
|
|
19
|
+
'English',
|
|
20
|
+
'Thai',
|
|
21
|
+
'Chinese',
|
|
22
|
+
'Russian',
|
|
23
|
+
'German',
|
|
24
|
+
'French',
|
|
25
|
+
'Spanish',
|
|
26
|
+
'Italian',
|
|
27
|
+
'Arabic',
|
|
28
|
+
'Korean',
|
|
29
|
+
'Japanese'
|
|
30
|
+
];
|
|
31
|
+
|
|
5
32
|
function toIsoDateString(val) {
|
|
6
33
|
if (!val) return null;
|
|
7
34
|
if (typeof val.toDate === 'function') return val.toDate().toISOString();
|
|
@@ -98,4 +125,27 @@ export function buildIndex(id, product) {
|
|
|
98
125
|
}
|
|
99
126
|
|
|
100
127
|
return document;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function requiresGuideLanguageSelection(product) {
|
|
131
|
+
const guidance = product?.guidance;
|
|
132
|
+
const type = typeof guidance?.type === 'string' ? guidance.type.trim() : '';
|
|
133
|
+
|
|
134
|
+
if (!type || UNGUIDED_TYPES.includes(type)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!Array.isArray(guidance.languages)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const validLanguages = guidance.languages
|
|
143
|
+
.map((lang) => (typeof lang === 'string' ? lang.trim() : ''))
|
|
144
|
+
.filter(Boolean);
|
|
145
|
+
|
|
146
|
+
if (validLanguages.length <= 1) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return validLanguages.some((lang) => !DEFAULT_GUIDE_LANGUAGES.has(lang.toLowerCase()));
|
|
101
151
|
}
|