tripstorekrabi-shared 1.6.5 → 1.7.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.
Files changed (3) hide show
  1. package/package.json +5 -2
  2. package/price.js +1 -1
  3. package/utils.js +5 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.6.5",
3
+ "version": "1.7.1",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer",
6
6
  "repository": {
@@ -13,7 +13,10 @@
13
13
  "./availability": "./availability.js"
14
14
  },
15
15
  "dependencies": {
16
- "dayjs": "^1.10.8"
16
+ "dayjs": "^1.11.2"
17
+ },
18
+ "scripts": {
19
+ "deploy": "npm publish"
17
20
  },
18
21
  "type": "module"
19
22
  }
package/price.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { getBookingType } from "./utils.js";
3
3
 
4
- export const MAX_PAX = 20;
4
+ export const MAX_PAX = 30;
5
5
 
6
6
  export function calculateProductPrice(booking, pricing, selling = true) {
7
7
  let type = pricing.type;
package/utils.js CHANGED
@@ -153,6 +153,7 @@ export function isHotelDropOff(value) {
153
153
 
154
154
  export function isAirportPickup(value) {
155
155
  value = value.toLowerCase();
156
+ value = value.replace('pick up', 'pickup').replace('picked up', 'pickup').replace('pick-up', 'pickup');
156
157
  return (value.includes("pickup") || value.includes("meet")) && value.includes("airport");
157
158
  }
158
159
 
@@ -307,7 +308,7 @@ export function getBookingSummary(booking, options = {}) {
307
308
  }
308
309
 
309
310
  if (booking.productDescription && booking.operator && booking.departureDate && booking.schedule && booking.leadTraveller) {
310
- let departureDate = dayjs(booking.departureDate.toDate()).format("DD.MM.YYYY");
311
+ let departureDate = dayjs(booking.departureDate.toDate()).tz("Asia/Bangkok").format("DD.MM.YYYY");
311
312
  summary += booking.productDescription + ", " + departureDate + ", " + booking.operator + ", " + booking.adults + ", " + booking.children + ", "
312
313
  + booking.infants + ", " + booking.leadTraveller;
313
314
 
@@ -438,10 +439,10 @@ export function validatePickupTime(pickupTime, schedule = "", context) {
438
439
  return checkTime(from, departureTime, context);
439
440
  }
440
441
  } else if (pickupTime.indexOf("-") != -1) {
441
- return context.createError({ message: `Invalid pickup time format, use spaces around the dash: ${pickupTime.replace(/ /g, '').replace("-", " - ")}` });
442
+ return context.createError({ message: `Invalid pickup time format, use spaces around the dash: ${pickupTime.replace(/ /g, '').replace("-", " - ")}`, path: context.path, });
442
443
  } else {
443
444
  if (!SCHEDULE_PATTERN.test(pickupTime)) {
444
- return context.createError({ message: "Invalid pickup time format: for example use '09:00' or '08:45 - 09:00'" });
445
+ return context.createError({ message: "Invalid pickup time format: for example use '09:00' or '08:45 - 09:00'", path: context.path, });
445
446
  } else {
446
447
  return checkTime(pickupTime, departureTime, context);
447
448
  }
@@ -460,7 +461,7 @@ function checkTime(pickupTimeValue, departureTimeValue, context) {
460
461
  let departureTimeValues = departureTimeValue.split(":");
461
462
  let departureTime = dayjs().hour(departureTimeValues[0]).minute(departureTimeValues[1]).second(0);
462
463
 
463
- return pickupTime.isSameOrBefore(departureTime) ? true : context.createError({ message: "Pickup time must be before or equals departure time" });
464
+ return pickupTime.isSameOrBefore(departureTime) ? true : context.createError({ message: "Pickup time must be before or equals departure time", path: context.path, });
464
465
  } catch (e) {
465
466
  return false;
466
467
  }