tripstorekrabi-shared 1.19.0 → 1.19.2
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/booking.js +91 -1
- package/package.json +2 -2
- package/utils.js +10 -0
package/booking.js
CHANGED
|
@@ -4,7 +4,7 @@ import utc from 'dayjs/plugin/utc.js';
|
|
|
4
4
|
import timezone from 'dayjs/plugin/timezone.js';
|
|
5
5
|
import { PAY_ON_TOUR, calculateTotalOperatorPrice } from './price.js';
|
|
6
6
|
import { nanoid } from 'nanoid';
|
|
7
|
-
import { isHotelPickup } from './utils.js';
|
|
7
|
+
import { CHECK_IN_LATE, IN_HOUSE, isAirportDropOff, isAirportPickup, isHotelPickup, isTrainStation, KEEP_PRIVATE, NO_PICKUP_HOTEL_YET, NO_ROOM, STAY_NEARBY } from './utils.js';
|
|
8
8
|
|
|
9
9
|
dayjs.extend(advancedFormat);
|
|
10
10
|
dayjs.extend(utc);
|
|
@@ -362,4 +362,94 @@ export function hasFood(product) {
|
|
|
362
362
|
item = item.toLowerCase();
|
|
363
363
|
return item.includes('breakfast') || item.includes('lunch') || item.includes('brunch') || item.includes('dinner');
|
|
364
364
|
}) != null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function createTodos(booking, product) {
|
|
368
|
+
let todos = {};
|
|
369
|
+
|
|
370
|
+
let pastTravelDate = dayjs(booking.departureDate.toDate()).isSameOrBefore(
|
|
371
|
+
dayjs().startOf('day'),
|
|
372
|
+
'day'
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
let customerBookingStatus = booking.customerBookingStatus;
|
|
376
|
+
if (customerBookingStatus !== 'Canceled') {
|
|
377
|
+
// check pickup hotel and room number
|
|
378
|
+
if (isHotelPickup(booking.startingPointDescription)) {
|
|
379
|
+
if (booking.startingPointDescription === NO_PICKUP_HOTEL_YET) {
|
|
380
|
+
todos.pickupHotel = "missing";
|
|
381
|
+
}
|
|
382
|
+
if (
|
|
383
|
+
booking.roomNumber !== NO_ROOM &&
|
|
384
|
+
booking.roomNumber !== IN_HOUSE &&
|
|
385
|
+
booking.roomNumber !== STAY_NEARBY &&
|
|
386
|
+
booking.roomNumber !== KEEP_PRIVATE &&
|
|
387
|
+
(!booking.roomNumber || booking.roomNumber === CHECK_IN_LATE)
|
|
388
|
+
) {
|
|
389
|
+
todos.roomNumber = "missing";
|
|
390
|
+
} else if (
|
|
391
|
+
!booking.roomConfirmed &&
|
|
392
|
+
booking.roomNumber !== NO_ROOM &&
|
|
393
|
+
booking.roomNumber !== IN_HOUSE &&
|
|
394
|
+
booking.roomNumber !== STAY_NEARBY &&
|
|
395
|
+
booking.roomNumber !== KEEP_PRIVATE &&
|
|
396
|
+
booking.roomNumber !== CHECK_IN_LATE &&
|
|
397
|
+
booking.sentToOperator === true
|
|
398
|
+
&& !pastTravelDate
|
|
399
|
+
) {
|
|
400
|
+
todos.roomNumber = "sendToOperator";
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (product && hasFood(product) && !pastTravelDate) {
|
|
405
|
+
if (!booking.dietary) {
|
|
406
|
+
todos.dietary = "missing";
|
|
407
|
+
} else if (!booking.dietaryConfirmed && booking.dietary?.length > 0 && booking.dietary !== 'None' && booking.sentToOperator === true) {
|
|
408
|
+
todos.dietary = "sendToOperator";
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// hotel dropoff
|
|
413
|
+
if (booking.productDescription.includes('with transfer to hotel')) {
|
|
414
|
+
if ((booking.dropoffHotel ?? "").length === 0) {
|
|
415
|
+
todos.dropoffHotel = "missing";
|
|
416
|
+
} else if (!booking.dropoffHotelConfirmed) {
|
|
417
|
+
todos.dropoffHotel = "sendToOperator";
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (isAirportPickup(booking.startingPointDescription)) {
|
|
422
|
+
if (!booking.flight) {
|
|
423
|
+
todos.airportPickupFlightDetails = "missing";
|
|
424
|
+
} else if (!booking.flightConfirmed) {
|
|
425
|
+
todos.airportPickupFlightDetails = "sendToOperator";
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (isAirportDropOff(booking.productDescription)) {
|
|
430
|
+
if (!booking.flight) {
|
|
431
|
+
todos.airportDropoffFlightDetails = "missing";
|
|
432
|
+
} else if (!booking.flightConfirmed) {
|
|
433
|
+
todos.airportDropoffFlightDetails = "sendToOperator";
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (isTrainStation(booking.startingPointDescription)) {
|
|
438
|
+
if (!booking.train) {
|
|
439
|
+
todos.railwayPickupTrainDetails = "missing";
|
|
440
|
+
} else if (!booking.trainConfirmed) {
|
|
441
|
+
todos.railwayPickupTrainDetails = "sendToOperator";
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (isTrainStation(booking.productDescription)) {
|
|
446
|
+
if (!booking.train) {
|
|
447
|
+
todos.railwayDropoffTrainDetails = "missing";
|
|
448
|
+
} else if (!booking.trainConfirmed) {
|
|
449
|
+
todos.railwayDropoffTrainDetails = "sendToOperator";
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return todos;
|
|
365
455
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tripstorekrabi-shared",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.2",
|
|
4
4
|
"description": "Shared library for Trip Store Krabi",
|
|
5
5
|
"author": "Stefan Sommer <tonprince@gmail.com>",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"dayjs": "^1.11.13",
|
|
19
|
-
"libphonenumber-js": "^1.11.
|
|
19
|
+
"libphonenumber-js": "^1.11.16",
|
|
20
20
|
"nanoid": "^5.0.9"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
package/utils.js
CHANGED
|
@@ -450,12 +450,22 @@ export function getBookingSummary(booking, options = {}) {
|
|
|
450
450
|
if (options.showPhoneNumber && booking.phoneNumber?.length > 0) {
|
|
451
451
|
summary += `, ${booking.phoneNumber}`;
|
|
452
452
|
}
|
|
453
|
+
|
|
454
|
+
if (options.showNotes) {
|
|
455
|
+
let notes = Object.values(booking.notes ?? {}).map((item) => item.description);
|
|
456
|
+
summary = [summary, ...notes].filter(Boolean).join(", ");
|
|
457
|
+
}
|
|
453
458
|
} else {
|
|
454
459
|
summary += '«THE BOOKING IS INCOMPLETE»';
|
|
455
460
|
|
|
456
461
|
if (options.showPhoneNumber && booking.phoneNumber?.length > 0) {
|
|
457
462
|
summary += `, ${booking.phoneNumber}`;
|
|
458
463
|
}
|
|
464
|
+
|
|
465
|
+
if (options.showNotes) {
|
|
466
|
+
let notes = Object.values(booking.notes ?? {}).map((item) => item.description);
|
|
467
|
+
summary = [summary, ...notes].filter(Boolean).join(", ");
|
|
468
|
+
}
|
|
459
469
|
}
|
|
460
470
|
|
|
461
471
|
return summary;
|