tripstorekrabi-shared 1.19.6 → 1.19.8

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 (2) hide show
  1. package/booking.js +70 -68
  2. package/package.json +1 -1
package/booking.js CHANGED
@@ -251,7 +251,7 @@ function addPhoneNumbers(phoneNumbers, phoneNumber) {
251
251
  }
252
252
  }
253
253
 
254
- export function getStartingPointMessage(booking, product) {
254
+ export function getStartingPointMessage(booking, product, options = { compact: false }) {
255
255
  let text = booking.startingPointDescription;
256
256
  if (booking.pickupTime.indexOf('-') != -1) {
257
257
  text +=
@@ -282,76 +282,78 @@ export function getStartingPointMessage(booking, product) {
282
282
 
283
283
  text += 'Kindly watch for staff representing ' + booking.operator + '.';
284
284
 
285
- if (booking.googleMapsLocation?.length > 0) {
286
- text += `\n\n${isHotelPickup(booking.startingPointDescription)
287
- ? 'PICKUP COORDINATES ON GOOGLE MAP'
288
- : 'MEETING COORDINATES ON GOOGLE MAP'
289
- }:\n${booking.googleMapsLocation}`;
290
- }
285
+ if (!options.compact) {
286
+ if (booking.googleMapsLocation?.length > 0) {
287
+ text += `\n\n${isHotelPickup(booking.startingPointDescription)
288
+ ? 'PICKUP COORDINATES ON GOOGLE MAP'
289
+ : 'MEETING COORDINATES ON GOOGLE MAP'
290
+ }:\n${booking.googleMapsLocation}`;
291
+ }
291
292
 
292
- if (product?.whatToBring?.length > 0) {
293
- text += '\n\nWHAT TO BRING: ' + product.whatToBring;
294
- }
293
+ if (product?.whatToBring?.length > 0) {
294
+ text += '\n\nWHAT TO BRING: ' + product.whatToBring;
295
+ }
295
296
 
296
- let notes = Object.values(booking.notes ?? {})
297
- .filter((item) => item.visibility.includes(CUSTOMER_NOTE))
298
- .map((item) => item.description);
299
- if (notes.length > 0) {
300
- text += '\n\nSPECIAL CUSTOMER NEEDS: ' + notes.join(', ');
301
- }
297
+ let notes = Object.values(booking.notes ?? {})
298
+ .filter((item) => item.visibility.includes(CUSTOMER_NOTE))
299
+ .map((item) => item.description);
300
+ if (notes.length > 0) {
301
+ text += '\n\nSPECIAL CUSTOMER NEEDS: ' + notes.join(', ');
302
+ }
302
303
 
303
- // add customer information from starting point
304
- let important = [];
305
- if (product) {
306
- let startingPoint = product.startingPoints.find(
307
- (item) => item.id === booking.startingPointId
308
- );
304
+ // add customer information from starting point
305
+ let important = [];
306
+ if (product) {
307
+ let startingPoint = product.startingPoints.find(
308
+ (item) => item.id === booking.startingPointId
309
+ );
309
310
 
310
- if (startingPoint?.customerInformation) {
311
- important.push(startingPoint.customerInformation.trim());
311
+ if (startingPoint?.customerInformation) {
312
+ important.push(startingPoint.customerInformation.trim());
313
+ }
312
314
  }
313
- }
314
315
 
315
- if (product?.customerInformation?.length > 0) {
316
- important.push(product.customerInformation);
317
- }
316
+ if (product?.customerInformation?.length > 0) {
317
+ important.push(product.customerInformation);
318
+ }
318
319
 
319
- if (important.length > 0) {
320
- text += '\n\nIMPORTANT INFORMATION: ' + important.join("\n\n");
321
- }
320
+ if (important.length > 0) {
321
+ text += '\n\nIMPORTANT INFORMATION: ' + important.join("\n\n");
322
+ }
322
323
 
323
- if (booking.dietary?.length > 0) {
324
- text += '\n\nDIETARY NEEDS: ' + booking.dietary;
325
- }
324
+ if (booking.dietary?.length > 0) {
325
+ text += '\n\nDIETARY NEEDS: ' + booking.dietary;
326
+ }
326
327
 
327
- let payOnTour = [];
328
- if (booking.nationalParkFee == PAY_ON_TOUR) {
329
- let item = 'As stated on the website, there is an entrance fee';
328
+ let payOnTour = [];
329
+ if (booking.nationalParkFee == PAY_ON_TOUR) {
330
+ let item = 'As stated on the website, there is an entrance fee';
330
331
 
331
- if (product?.nationalPark) {
332
- item += ' to ' + product?.nationalPark.title;
333
- }
332
+ if (product?.nationalPark) {
333
+ item += ' to ' + product?.nationalPark.title;
334
+ }
334
335
 
335
- if (product?.nationalPark?.pricing) {
336
- item +=
337
- ' of ' +
338
- product.nationalPark.pricing.adult +
339
- ' THB per adult and ' +
340
- product.nationalPark.pricing.child +
341
- ' THB per child';
342
- }
343
- item += ' to be paid at the point of entry';
336
+ if (product?.nationalPark?.pricing) {
337
+ item +=
338
+ ' of ' +
339
+ product.nationalPark.pricing.adult +
340
+ ' THB per adult and ' +
341
+ product.nationalPark.pricing.child +
342
+ ' THB per child';
343
+ }
344
+ item += ' to be paid at the point of entry';
344
345
 
345
- payOnTour.push(` • ${item}`);
346
- }
346
+ payOnTour.push(` • ${item}`);
347
+ }
347
348
 
348
- let extraPayments = Object.values(booking.extraPayments)
349
- .filter((item) => !item.disabled && item.paymentMethod === PAY_ON_TOUR)
350
- .map((item) => ` • ${item.description}: ${item.price} THB`);
351
- payOnTour = [...payOnTour, ...extraPayments];
352
- if (payOnTour.length > 0) {
353
- text += '\n\nTO BE PAID ON TOUR:\n' + payOnTour.join('\n');
354
- text += '\n\nPlease bring the total amount in cash to the trip.';
349
+ let extraPayments = Object.values(booking.extraPayments)
350
+ .filter((item) => !item.disabled && item.paymentMethod === PAY_ON_TOUR)
351
+ .map((item) => ` • ${item.description}: ${item.price} THB`);
352
+ payOnTour = [...payOnTour, ...extraPayments];
353
+ if (payOnTour.length > 0) {
354
+ text += '\n\nTO BE PAID ON TOUR:\n' + payOnTour.join('\n');
355
+ text += '\n\nPlease bring the total amount in cash to the trip.';
356
+ }
355
357
  }
356
358
 
357
359
  return text;
@@ -373,8 +375,8 @@ export function createTodos(booking, product) {
373
375
  );
374
376
 
375
377
  let customerBookingStatus = booking.customerBookingStatus;
376
- if (customerBookingStatus !== 'Canceled') {
377
- if (isHotelPickup(booking.startingPointDescription) && !pastTravelDate) {
378
+ if (customerBookingStatus !== 'Canceled' && !pastTravelDate) {
379
+ if (isHotelPickup(booking.startingPointDescription)) {
378
380
  if (booking.startingPointDescription === NO_PICKUP_HOTEL_YET) {
379
381
  todos.pickupHotel = "missing";
380
382
  }
@@ -386,7 +388,7 @@ export function createTodos(booking, product) {
386
388
  booking.roomNumber !== STAY_NEARBY &&
387
389
  booking.roomNumber !== KEEP_PRIVATE &&
388
390
  booking.roomNumber !== CHECK_IN_LATE &&
389
- !booking.roomNumber &&
391
+ !booking.roomNumber
390
392
  ) {
391
393
  todos.roomNumber = "missing";
392
394
  } else if (
@@ -397,13 +399,13 @@ export function createTodos(booking, product) {
397
399
  booking.roomNumber !== KEEP_PRIVATE &&
398
400
  booking.roomNumber !== CHECK_IN_LATE &&
399
401
  booking.roomNumber &&
400
- booking.sentToOperator === true &&
402
+ booking.sentToOperator === true
401
403
  ) {
402
404
  todos.roomNumber = "sendToOperator";
403
405
  }
404
406
  }
405
407
 
406
- if (product && hasFood(product) && !pastTravelDate) {
408
+ if (product && hasFood(product)) {
407
409
  if (!booking.dietary) {
408
410
  todos.dietary = "missing";
409
411
  } else if (!booking.dietaryConfirmed && booking.dietary?.length > 0 && booking.dietary !== 'None' && booking.sentToOperator === true) {
@@ -412,7 +414,7 @@ export function createTodos(booking, product) {
412
414
  }
413
415
 
414
416
  // hotel dropoff
415
- if (booking.productDescription.includes('with transfer to hotel') && !pastTravelDate) {
417
+ if (booking.productDescription.includes('with transfer to hotel')) {
416
418
  if ((booking.dropoffHotel ?? "").length === 0) {
417
419
  todos.dropoffHotel = "missing";
418
420
  } else if (!booking.dropoffHotelConfirmed) {
@@ -420,7 +422,7 @@ export function createTodos(booking, product) {
420
422
  }
421
423
  }
422
424
 
423
- if (isAirportPickup(booking.startingPointDescription) && !pastTravelDate) {
425
+ if (isAirportPickup(booking.startingPointDescription)) {
424
426
  if (!booking.flight) {
425
427
  todos.inboundFlightDetails = "missing";
426
428
  } else if (!booking.flightConfirmed) {
@@ -428,7 +430,7 @@ export function createTodos(booking, product) {
428
430
  }
429
431
  }
430
432
 
431
- if (isAirportDropOff(booking.productDescription) && !pastTravelDate) {
433
+ if (isAirportDropOff(booking.productDescription)) {
432
434
  if (!booking.flight) {
433
435
  todos.outboundFlightDetails = "missing";
434
436
  } else if (!booking.flightConfirmed) {
@@ -436,7 +438,7 @@ export function createTodos(booking, product) {
436
438
  }
437
439
  }
438
440
 
439
- if (isTrainStation(booking.startingPointDescription) && !pastTravelDate) {
441
+ if (isTrainStation(booking.startingPointDescription)) {
440
442
  if (!booking.train) {
441
443
  todos.inboundTrainDetails = "missing";
442
444
  } else if (!booking.trainConfirmed) {
@@ -444,7 +446,7 @@ export function createTodos(booking, product) {
444
446
  }
445
447
  }
446
448
 
447
- if (isTrainStation(booking.productDescription) && !pastTravelDate) {
449
+ if (isTrainStation(booking.productDescription)) {
448
450
  if (!booking.train) {
449
451
  todos.outboundTrainDetails = "missing";
450
452
  } else if (!booking.trainConfirmed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.19.6",
3
+ "version": "1.19.8",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {