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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/product.js +50 -0
  3. package/utils.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.26.4",
3
+ "version": "1.26.5",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
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
  }
package/utils.js CHANGED
@@ -208,8 +208,6 @@ export function isHotelPickup(value) {
208
208
  );
209
209
  }
210
210
 
211
-
212
-
213
211
  export function isHotelDropOff(value) {
214
212
  value = value.toLowerCase();
215
213
  return (