@meetelise/chat 1.74.0 → 1.75.0
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/dist/src/WebComponent/SchedulerV2/booking-confirmation.d.ts +2 -0
- package/dist/src/WebComponent/SchedulerV2/itinerary-editor.d.ts +3 -0
- package/dist/src/WebComponent/SchedulerV2/schedulerRequests.d.ts +2 -0
- package/dist/src/WebComponent/SchedulerV2/tour-scheduler-v2.d.ts +4 -0
- package/dist/src/WebComponent/SchedulerV2/tourItineraryApi.d.ts +12 -0
- package/dist/src/WebComponent/SchedulerV2/tourTimes.d.ts +2 -0
- package/package.json +1 -1
- package/public/dist/index.js +388 -394
- package/src/WebComponent/SchedulerV2/booking-confirmation.ts +13 -8
- package/src/WebComponent/SchedulerV2/itinerary-editor.ts +40 -17
- package/src/WebComponent/SchedulerV2/schedulerRequests.ts +10 -0
- package/src/WebComponent/SchedulerV2/tour-scheduler-v2.ts +53 -0
- package/src/WebComponent/SchedulerV2/tourItineraryApi.ts +12 -0
- package/src/WebComponent/SchedulerV2/tourTimes.ts +12 -0
- package/src/tourSchedulerV2Booking.test.ts +94 -6
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
TourTypeId,
|
|
13
13
|
} from "./tourItineraryApi";
|
|
14
14
|
import {
|
|
15
|
+
formatLeg,
|
|
15
16
|
formatMonthDay,
|
|
16
17
|
formatTime,
|
|
17
18
|
formatTimeRange,
|
|
@@ -28,6 +29,7 @@ export interface ConfirmedStop {
|
|
|
28
29
|
/** The server's prospect-facing reason, for a failed stop. */
|
|
29
30
|
error: string | null;
|
|
30
31
|
distanceFromPrevMi: number | null;
|
|
32
|
+
travelMinutesFromPrev: number | null;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -62,7 +64,9 @@ export class BookingConfirmation extends LitElement {
|
|
|
62
64
|
booked.length === 1 ? first.community.name : "",
|
|
63
65
|
this.tourType ? TOUR_TYPES[this.tourType].heading : "",
|
|
64
66
|
];
|
|
65
|
-
|
|
67
|
+
// Stops on different days each show their own date, so the summary names none.
|
|
68
|
+
const days = new Set(booked.map((s) => s.start && isoDate(s.start)));
|
|
69
|
+
if (first.start && days.size === 1) {
|
|
66
70
|
const zone = first.community.timezone
|
|
67
71
|
? ` ${getTimezoneAbbreviation(first.community.timezone)}`
|
|
68
72
|
: "";
|
|
@@ -77,6 +81,13 @@ export class BookingConfirmation extends LitElement {
|
|
|
77
81
|
return parts.filter(Boolean).join(" · ");
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
private renderLeg(stop: ConfirmedStop): TemplateResult | string {
|
|
85
|
+
const leg = formatLeg(stop.distanceFromPrevMi, stop.travelMinutesFromPrev);
|
|
86
|
+
return leg
|
|
87
|
+
? html`${leg}<span class="sr-only"> from the previous stop</span>`
|
|
88
|
+
: "";
|
|
89
|
+
}
|
|
90
|
+
|
|
80
91
|
private renderStops(): TemplateResult | string {
|
|
81
92
|
if (this.stops.length < 2) return "";
|
|
82
93
|
return html`<ol class="stops">
|
|
@@ -84,13 +95,7 @@ export class BookingConfirmation extends LitElement {
|
|
|
84
95
|
(stop, i) => html`<li>
|
|
85
96
|
${i > 0
|
|
86
97
|
? html`<p class="image-card-subtitle leg">
|
|
87
|
-
${stop
|
|
88
|
-
? html`${stop.distanceFromPrevMi.toFixed(1)} mi<span
|
|
89
|
-
class="sr-only"
|
|
90
|
-
>
|
|
91
|
-
from the previous stop</span
|
|
92
|
-
>`
|
|
93
|
-
: ""}
|
|
98
|
+
${this.renderLeg(stop)}
|
|
94
99
|
</p>`
|
|
95
100
|
: ""}
|
|
96
101
|
<div class="floorplan-image-card">
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
} from "./tourItineraryApi";
|
|
33
33
|
import {
|
|
34
34
|
dateFromIsoDate,
|
|
35
|
+
formatLeg,
|
|
35
36
|
formatMonthDay,
|
|
36
37
|
formatTime,
|
|
37
38
|
formatTimeRange,
|
|
@@ -255,25 +256,36 @@ export class ItineraryEditor extends LitElement {
|
|
|
255
256
|
: ""}`;
|
|
256
257
|
}
|
|
257
258
|
|
|
258
|
-
|
|
259
|
+
/** Today's date picker over `dates`, reporting a picked day other than `date`. */
|
|
260
|
+
private renderDatePicker(
|
|
261
|
+
dates: string[] = this.bookableDates,
|
|
262
|
+
date: string | null = this.date,
|
|
263
|
+
pick: (picked: string) => void = (picked) =>
|
|
264
|
+
emit(this, "date-change", { date: picked })
|
|
265
|
+
): TemplateResult {
|
|
259
266
|
// The month of the chosen or first bookable date, which may not be this month.
|
|
260
|
-
const shown =
|
|
267
|
+
const shown = date ?? dates[0];
|
|
261
268
|
return html`<date-picker
|
|
262
269
|
outlined
|
|
263
270
|
.shownMonth=${shown?.slice(0, 7)}
|
|
264
271
|
.availabilities=${Object.fromEntries(
|
|
265
|
-
|
|
272
|
+
dates.map((d) => [d, [dateFromIsoDate(d)]])
|
|
266
273
|
)}
|
|
267
|
-
.defaultDate=${
|
|
274
|
+
.defaultDate=${date ? dateFromIsoDate(date) : undefined}
|
|
268
275
|
@change=${(e: Event) => {
|
|
269
276
|
const picked = (e.target as DatePicker).selectedDate;
|
|
270
|
-
if (picked && toIsoDate(picked) !==
|
|
271
|
-
emit(this, "date-change", { date: toIsoDate(picked) });
|
|
272
|
-
}
|
|
277
|
+
if (picked && toIsoDate(picked) !== date) pick(toIsoDate(picked));
|
|
273
278
|
}}
|
|
274
279
|
></date-picker>`;
|
|
275
280
|
}
|
|
276
281
|
|
|
282
|
+
/** One stop's own day: moving it there makes it a separate tour. */
|
|
283
|
+
private renderStopDatePicker(stop: PlanStop): TemplateResult {
|
|
284
|
+
return this.renderDatePicker(stop.dates, isoDate(stop.start), (date) =>
|
|
285
|
+
emit(this, "stop-date-change", { buildingId: stop.building_id, date })
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
277
289
|
private renderTimePicker(stop: PlanStop): TemplateResult {
|
|
278
290
|
const times = [...new Set([stop.start, ...stop.alternatives])].sort();
|
|
279
291
|
return html`<time-picker
|
|
@@ -338,14 +350,20 @@ export class ItineraryEditor extends LitElement {
|
|
|
338
350
|
const newIndex = ids.indexOf(stop.building_id);
|
|
339
351
|
const editing = this.editingTimeFor === stop.building_id;
|
|
340
352
|
const canReorder = !stop.fixed && ids.length > 1;
|
|
341
|
-
// With no other time to pick,
|
|
353
|
+
// With no other day or time to pick, they're plain text rather than a picker.
|
|
342
354
|
const canChangeTime =
|
|
343
355
|
!stop.fixed && stop.alternatives.some((t) => t !== stop.start);
|
|
356
|
+
const canChangeDate =
|
|
357
|
+
!stop.fixed && (stop.dates ?? []).some((d) => d !== isoDate(stop.start));
|
|
344
358
|
const time = `${formatMonthDay(isoDate(stop.start))} · ${formatTimeRange(
|
|
345
359
|
stop.start,
|
|
346
360
|
stop.end
|
|
347
361
|
)}`;
|
|
348
362
|
const dragging = this.dragIndex !== null;
|
|
363
|
+
const leg = formatLeg(
|
|
364
|
+
stop.distance_from_prev_mi,
|
|
365
|
+
stop.travel_minutes_from_prev
|
|
366
|
+
);
|
|
349
367
|
return html`<li
|
|
350
368
|
class=${classMap({
|
|
351
369
|
"stop-item": true,
|
|
@@ -359,12 +377,8 @@ export class ItineraryEditor extends LitElement {
|
|
|
359
377
|
>
|
|
360
378
|
${index > 0
|
|
361
379
|
? html`<p class="image-card-subtitle leg">
|
|
362
|
-
${
|
|
363
|
-
? html`${
|
|
364
|
-
class="sr-only"
|
|
365
|
-
>
|
|
366
|
-
from the previous stop</span
|
|
367
|
-
>`
|
|
380
|
+
${leg
|
|
381
|
+
? html`${leg}<span class="sr-only"> from the previous stop</span>`
|
|
368
382
|
: ""}
|
|
369
383
|
</p>`
|
|
370
384
|
: ""}
|
|
@@ -412,7 +426,7 @@ export class ItineraryEditor extends LitElement {
|
|
|
412
426
|
<p class="image-card-subtitle">
|
|
413
427
|
${formatAddress(community?.address ?? null)}
|
|
414
428
|
</p>
|
|
415
|
-
${!canChangeTime
|
|
429
|
+
${!canChangeTime && !canChangeDate
|
|
416
430
|
? html`<p class="stop-time">
|
|
417
431
|
${time}
|
|
418
432
|
${stop.fixed
|
|
@@ -422,13 +436,22 @@ export class ItineraryEditor extends LitElement {
|
|
|
422
436
|
: html`<button
|
|
423
437
|
class="stop-time edit-time"
|
|
424
438
|
aria-expanded=${String(editing)}
|
|
425
|
-
aria-label=${`Change the
|
|
439
|
+
aria-label=${`Change the ${
|
|
440
|
+
canChangeDate ? "date or time" : "time"
|
|
441
|
+
} at ${community?.name ?? ""}`}
|
|
426
442
|
@click=${() =>
|
|
427
443
|
(this.editingTimeFor = editing ? null : stop.building_id)}
|
|
428
444
|
>
|
|
429
445
|
${time} ${PencilIcon()}
|
|
430
446
|
</button>`}
|
|
431
|
-
${editing ? this.
|
|
447
|
+
${editing && canChangeDate ? this.renderStopDatePicker(stop) : ""}
|
|
448
|
+
${
|
|
449
|
+
// While /plan answers, these are the old plan's times, which may
|
|
450
|
+
// be on the stop's old day.
|
|
451
|
+
editing && canChangeTime && !this.loading
|
|
452
|
+
? this.renderTimePicker(stop)
|
|
453
|
+
: ""
|
|
454
|
+
}
|
|
432
455
|
</div>
|
|
433
456
|
${!stop.fixed &&
|
|
434
457
|
(ids.length > 1 || this.problems.length > 0 || this.stopsOnly)
|
|
@@ -20,6 +20,8 @@ export interface ItineraryChoice {
|
|
|
20
20
|
firstStart: string | null;
|
|
21
21
|
/** ISO starts picked for later new stops, by building id. */
|
|
22
22
|
laterStarts: Record<number, string>;
|
|
23
|
+
/** "YYYY-MM-DD" days new stops moved to on their own, away from `date`, by building id. */
|
|
24
|
+
stopDates: Record<number, string>;
|
|
23
25
|
/** Booked events this itinerary extends, in order; the last one is fixed first. */
|
|
24
26
|
existingEventIds: number[];
|
|
25
27
|
}
|
|
@@ -31,6 +33,13 @@ export const buildPlanRequest = (choice: ItineraryChoice): PlanRequest => {
|
|
|
31
33
|
.filter((id) => choice.laterStarts[id])
|
|
32
34
|
.map((id) => [String(id), choice.laterStarts[id]])
|
|
33
35
|
);
|
|
36
|
+
const stopDates = Object.fromEntries(
|
|
37
|
+
choice.buildingIds
|
|
38
|
+
.filter(
|
|
39
|
+
(id) => choice.stopDates[id] && choice.stopDates[id] !== choice.date
|
|
40
|
+
)
|
|
41
|
+
.map((id) => [String(id), choice.stopDates[id]])
|
|
42
|
+
);
|
|
34
43
|
const fixedEventId =
|
|
35
44
|
choice.existingEventIds[choice.existingEventIds.length - 1];
|
|
36
45
|
return {
|
|
@@ -39,6 +48,7 @@ export const buildPlanRequest = (choice: ItineraryChoice): PlanRequest => {
|
|
|
39
48
|
date: choice.date,
|
|
40
49
|
start_time: choice.firstStart,
|
|
41
50
|
stop_starts: laterStarts,
|
|
51
|
+
stop_dates: stopDates,
|
|
42
52
|
fixed_first:
|
|
43
53
|
fixedEventId === undefined ? null : { calendar_event_id: fixedEventId },
|
|
44
54
|
};
|
|
@@ -155,6 +155,8 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
155
155
|
@state() private date: string | null = null;
|
|
156
156
|
@state() private firstStart: string | null = null;
|
|
157
157
|
@state() private laterStarts: Record<number, string> = {};
|
|
158
|
+
/** Stops the prospect moved to their own day, away from `date`. */
|
|
159
|
+
@state() private stopDates: Record<number, string> = {};
|
|
158
160
|
@state() private plan: PlanResponse | null = null;
|
|
159
161
|
@state() private planLoading = false;
|
|
160
162
|
@state() private planError: string | null = null;
|
|
@@ -354,6 +356,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
354
356
|
this.plan = null;
|
|
355
357
|
this.firstStart = null;
|
|
356
358
|
this.laterStarts = {};
|
|
359
|
+
this.stopDates = {};
|
|
357
360
|
this.linkTourType = null;
|
|
358
361
|
this.notice = null;
|
|
359
362
|
this.bookingError = null;
|
|
@@ -371,6 +374,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
371
374
|
date: this.date ?? toIsoDate(new Date()),
|
|
372
375
|
firstStart: this.firstStart,
|
|
373
376
|
laterStarts: this.laterStarts,
|
|
377
|
+
stopDates: this.stopDates,
|
|
374
378
|
existingEventIds: this.existingEventIds,
|
|
375
379
|
};
|
|
376
380
|
}
|
|
@@ -402,7 +406,11 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
402
406
|
if (!plan.tour_types.includes(choice.tourType)) {
|
|
403
407
|
if (plan.tour_types.length === 0) break;
|
|
404
408
|
this.tourType = plan.tour_types[0];
|
|
409
|
+
this.stopDates = {};
|
|
405
410
|
} else if (
|
|
411
|
+
// bookable_dates are the days every stop chains on together, which
|
|
412
|
+
// the tour's day needn't be once a stop is on its own day.
|
|
413
|
+
Object.keys(choice.stopDates).length === 0 &&
|
|
406
414
|
plan.bookable_dates.length > 0 &&
|
|
407
415
|
!plan.bookable_dates.includes(choice.date)
|
|
408
416
|
) {
|
|
@@ -515,6 +523,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
515
523
|
this.tourType = tourType;
|
|
516
524
|
this.firstStart = null;
|
|
517
525
|
this.laterStarts = {};
|
|
526
|
+
this.stopDates = {};
|
|
518
527
|
void this.runPlan();
|
|
519
528
|
}
|
|
520
529
|
|
|
@@ -524,9 +533,40 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
524
533
|
tourType: this.tourType,
|
|
525
534
|
buildingId: this.buildingId,
|
|
526
535
|
});
|
|
536
|
+
// The whole tour moves, including any stop on its own day.
|
|
527
537
|
this.date = date;
|
|
528
538
|
this.firstStart = null;
|
|
529
539
|
this.laterStarts = {};
|
|
540
|
+
this.stopDates = {};
|
|
541
|
+
void this.runPlan();
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
private stopDatesWithout(buildingId: number): Record<number, string> {
|
|
545
|
+
return Object.fromEntries(
|
|
546
|
+
Object.entries(this.stopDates).filter(([id]) => Number(id) !== buildingId)
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
private onStopDate(buildingId: number, date: string): void {
|
|
551
|
+
const index = this.selectedIds.indexOf(buildingId);
|
|
552
|
+
if (index < 0) return;
|
|
553
|
+
pushGtmEvent("tourStopDateSelected", {
|
|
554
|
+
tourType: this.tourType,
|
|
555
|
+
buildingId: this.buildingId,
|
|
556
|
+
stopNumber: index + 1,
|
|
557
|
+
});
|
|
558
|
+
const others = this.stopDatesWithout(buildingId);
|
|
559
|
+
this.stopDates =
|
|
560
|
+
date === this.date ? others : { ...others, [buildingId]: date };
|
|
561
|
+
// The stop starts afresh on its new day, and the stops after it may move,
|
|
562
|
+
// so their own picks are dropped.
|
|
563
|
+
if (index === 0) this.firstStart = null;
|
|
564
|
+
this.laterStarts = Object.fromEntries(
|
|
565
|
+
this.selectedIds
|
|
566
|
+
.slice(1, index)
|
|
567
|
+
.filter((id) => this.laterStarts[id])
|
|
568
|
+
.map((id) => [id, this.laterStarts[id]])
|
|
569
|
+
);
|
|
530
570
|
void this.runPlan();
|
|
531
571
|
}
|
|
532
572
|
|
|
@@ -587,6 +627,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
587
627
|
if (this.selectedIds[0] === buildingId) this.firstStart = null;
|
|
588
628
|
this.selectedIds = remaining;
|
|
589
629
|
this.laterStarts = {};
|
|
630
|
+
this.stopDates = this.stopDatesWithout(buildingId);
|
|
590
631
|
void this.runPlan();
|
|
591
632
|
}
|
|
592
633
|
|
|
@@ -748,6 +789,8 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
748
789
|
error: stop.error?.message ?? null,
|
|
749
790
|
distanceFromPrevMi:
|
|
750
791
|
plannedStops.get(stop.building_id)?.distance_from_prev_mi ?? null,
|
|
792
|
+
travelMinutesFromPrev:
|
|
793
|
+
plannedStops.get(stop.building_id)?.travel_minutes_from_prev ?? null,
|
|
751
794
|
};
|
|
752
795
|
});
|
|
753
796
|
const bookedStops = response.stops.filter(
|
|
@@ -847,6 +890,13 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
847
890
|
count: 1,
|
|
848
891
|
mode: "extend",
|
|
849
892
|
});
|
|
893
|
+
// The list was fetched after the last stop, on that stop's day, so the new
|
|
894
|
+
// stop joins it there.
|
|
895
|
+
const lastDay =
|
|
896
|
+
this.stopDates[this.selectedIds[this.selectedIds.length - 1]];
|
|
897
|
+
if (lastDay) {
|
|
898
|
+
this.stopDates = { ...this.stopDates, [community.building_id]: lastDay };
|
|
899
|
+
}
|
|
850
900
|
this.selectedIds = [...this.selectedIds, community.building_id];
|
|
851
901
|
void this.runPlan();
|
|
852
902
|
}
|
|
@@ -1149,6 +1199,9 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1149
1199
|
@stop-time-change=${(
|
|
1150
1200
|
e: CustomEvent<{ buildingId: number; start: string }>
|
|
1151
1201
|
) => this.onStopTime(e.detail.buildingId, e.detail.start)}
|
|
1202
|
+
@stop-date-change=${(
|
|
1203
|
+
e: CustomEvent<{ buildingId: number; date: string }>
|
|
1204
|
+
) => this.onStopDate(e.detail.buildingId, e.detail.date)}
|
|
1152
1205
|
@stops-reorder=${(e: CustomEvent<{ buildingIds: number[] }>) =>
|
|
1153
1206
|
this.onReorder(e.detail.buildingIds)}
|
|
1154
1207
|
@stop-remove=${(e: CustomEvent<{ buildingId: number }>) =>
|
|
@@ -101,6 +101,8 @@ export interface PlanRequest {
|
|
|
101
101
|
start_time: string | null;
|
|
102
102
|
/** Times picked for later stops, by building id; empty when none are picked. */
|
|
103
103
|
stop_starts: Record<string, string>;
|
|
104
|
+
/** A stop's own day when it isn't `date`, by building id; empty when none is moved. */
|
|
105
|
+
stop_dates: Record<string, string>;
|
|
104
106
|
fixed_first: { calendar_event_id: number } | null;
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -110,7 +112,17 @@ export interface PlanStop {
|
|
|
110
112
|
end: string;
|
|
111
113
|
timezone: string;
|
|
112
114
|
distance_from_prev_mi: number | null;
|
|
115
|
+
/**
|
|
116
|
+
* Whole minutes to drive here from the stop before, already left free in the
|
|
117
|
+
* times. Missing from a server that predates the field.
|
|
118
|
+
*/
|
|
119
|
+
travel_minutes_from_prev?: number | null;
|
|
113
120
|
alternatives: string[];
|
|
121
|
+
/**
|
|
122
|
+
* The days this stop could move to on its own, within the next 30. Empty once
|
|
123
|
+
* a stop is booked, and missing from a server that predates the field.
|
|
124
|
+
*/
|
|
125
|
+
dates?: string[];
|
|
114
126
|
fixed: boolean;
|
|
115
127
|
}
|
|
116
128
|
|
|
@@ -67,6 +67,18 @@ export const formatMonthDay = (date: string): string =>
|
|
|
67
67
|
export const formatLongDate = (date: string): string =>
|
|
68
68
|
format(dateFromIsoDate(date), "EEE, MMM d, yyyy");
|
|
69
69
|
|
|
70
|
+
/** "1.8 mi · 12 min drive" between two stops, or "" when neither is known. */
|
|
71
|
+
export const formatLeg = (
|
|
72
|
+
distanceMi: number | null,
|
|
73
|
+
travelMinutes: number | null | undefined
|
|
74
|
+
): string =>
|
|
75
|
+
[
|
|
76
|
+
distanceMi !== null ? `${distanceMi.toFixed(1)} mi` : null,
|
|
77
|
+
travelMinutes != null ? `${travelMinutes} min drive` : null,
|
|
78
|
+
]
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join(" · ");
|
|
81
|
+
|
|
70
82
|
/** A Date as the "YYYY-MM-DD" the API uses. */
|
|
71
83
|
export const toIsoDate = (date: Date): string => format(date, "yyyy-MM-dd");
|
|
72
84
|
|
|
@@ -42,6 +42,7 @@ const header = (request: FakeRequest, name: string): string | undefined =>
|
|
|
42
42
|
)?.[1];
|
|
43
43
|
|
|
44
44
|
const DATE = "2026-10-30";
|
|
45
|
+
const NEXT_DATE = "2026-10-31";
|
|
45
46
|
const ANCHOR = 12;
|
|
46
47
|
const LINDEN = 40;
|
|
47
48
|
const CEDAR = 7;
|
|
@@ -100,12 +101,14 @@ const fakeBackend = ({
|
|
|
100
101
|
sessionTokens: string[];
|
|
101
102
|
communityQueries: URLSearchParams[];
|
|
102
103
|
plannedTourTypes: TourTypeId[];
|
|
104
|
+
plans: PlanRequest[];
|
|
103
105
|
} => {
|
|
104
106
|
const bookings: BookingRequest[] = [];
|
|
105
107
|
const keys: string[] = [];
|
|
106
108
|
const sessionTokens: string[] = [];
|
|
107
109
|
const communityQueries: URLSearchParams[] = [];
|
|
108
110
|
const plannedTourTypes: TourTypeId[] = [];
|
|
111
|
+
const plans: PlanRequest[] = [];
|
|
109
112
|
let nextEventId = 990;
|
|
110
113
|
let dropped = false;
|
|
111
114
|
const group = (extend: boolean): CommunitiesResponse => ({
|
|
@@ -139,17 +142,25 @@ const fakeBackend = ({
|
|
|
139
142
|
});
|
|
140
143
|
start += 30;
|
|
141
144
|
}
|
|
145
|
+
// Stops on their own day chain from 10:00 that day.
|
|
146
|
+
const ownDayStarts: Record<string, number> = {};
|
|
142
147
|
request.building_ids.forEach((building_id) => {
|
|
148
|
+
const ownDay = request.stop_dates[String(building_id)];
|
|
149
|
+
const stopStart = (minutes: number) =>
|
|
150
|
+
ownDay ? at(minutes).replace(DATE, ownDay) : at(minutes);
|
|
151
|
+
const minutes = ownDay ? ownDayStarts[ownDay] ?? 10 * 60 : start;
|
|
143
152
|
stops.push({
|
|
144
153
|
building_id,
|
|
145
|
-
start:
|
|
146
|
-
end:
|
|
154
|
+
start: stopStart(minutes),
|
|
155
|
+
end: stopStart(minutes + 30),
|
|
147
156
|
timezone: "America/Chicago",
|
|
148
|
-
distance_from_prev_mi: stops.length > 0 ? 1.8 : null,
|
|
149
|
-
alternatives: [
|
|
157
|
+
distance_from_prev_mi: stops.length > 0 && !ownDay ? 1.8 : null,
|
|
158
|
+
alternatives: [stopStart(minutes + 15)],
|
|
159
|
+
dates: [DATE, NEXT_DATE],
|
|
150
160
|
fixed: false,
|
|
151
161
|
});
|
|
152
|
-
|
|
162
|
+
if (ownDay) ownDayStarts[ownDay] = minutes + 30;
|
|
163
|
+
else start += 30;
|
|
153
164
|
});
|
|
154
165
|
// As /plan does: dates and times only for a tour type the building offers.
|
|
155
166
|
const offered = tourTypes.includes(request.tour_type);
|
|
@@ -213,6 +224,7 @@ const fakeBackend = ({
|
|
|
213
224
|
if (body.stop_starts === null) return json(422, null);
|
|
214
225
|
if (failPlan) return json(500, null);
|
|
215
226
|
plannedTourTypes.push(body.tour_type);
|
|
227
|
+
plans.push(body);
|
|
216
228
|
return json(200, plan(body));
|
|
217
229
|
}
|
|
218
230
|
if (pathname === "/platformApi/webchat/tour-itineraries") {
|
|
@@ -234,7 +246,14 @@ const fakeBackend = ({
|
|
|
234
246
|
return json(404, null);
|
|
235
247
|
}, 0);
|
|
236
248
|
};
|
|
237
|
-
return {
|
|
249
|
+
return {
|
|
250
|
+
bookings,
|
|
251
|
+
keys,
|
|
252
|
+
sessionTokens,
|
|
253
|
+
communityQueries,
|
|
254
|
+
plannedTourTypes,
|
|
255
|
+
plans,
|
|
256
|
+
};
|
|
238
257
|
};
|
|
239
258
|
|
|
240
259
|
const waitFor = async <T>(
|
|
@@ -441,6 +460,75 @@ it("extends a booking without asking for contact details again, sending the book
|
|
|
441
460
|
});
|
|
442
461
|
});
|
|
443
462
|
|
|
463
|
+
it("moves an added stop to its own day, keeping the booked tour's day, adds the next stop on that day, and books them at that day's times", async () => {
|
|
464
|
+
const { bookings, plans } = fakeBackend();
|
|
465
|
+
const scheduler = mount();
|
|
466
|
+
|
|
467
|
+
await bookAndAddLinden(scheduler);
|
|
468
|
+
const editor = await waitFor(() =>
|
|
469
|
+
inScheduler<ItineraryEditor>(scheduler, "itinerary-editor")
|
|
470
|
+
);
|
|
471
|
+
// The booked stop never moves, so the tour has no date picker of its own.
|
|
472
|
+
expect(editor.shadowRoot?.querySelector(".date-header")).to.equal(null);
|
|
473
|
+
const edit = await waitFor(() =>
|
|
474
|
+
editor.shadowRoot?.querySelector<HTMLButtonElement>(".edit-time")
|
|
475
|
+
);
|
|
476
|
+
expect(edit.getAttribute("aria-label")).to.equal(
|
|
477
|
+
"Change the date or time at The Linden"
|
|
478
|
+
);
|
|
479
|
+
edit.click();
|
|
480
|
+
const picker = await waitFor(() =>
|
|
481
|
+
editor.shadowRoot?.querySelector<HTMLElement & { selectedDate?: Date }>(
|
|
482
|
+
"date-picker"
|
|
483
|
+
)
|
|
484
|
+
);
|
|
485
|
+
picker.selectedDate = new Date(2026, 9, 31);
|
|
486
|
+
// Until /plan answers, the times shown would be the old day's. The picker
|
|
487
|
+
// asks for the plan at once, and it answers only after these renders.
|
|
488
|
+
await scheduler.updateComplete;
|
|
489
|
+
await editor.updateComplete;
|
|
490
|
+
expect(editor.loading).to.equal(true);
|
|
491
|
+
expect(editor.shadowRoot?.querySelector("time-picker")).to.equal(null);
|
|
492
|
+
await waitFor(() =>
|
|
493
|
+
editor.stops.some((stop) => stop.start === `${NEXT_DATE}T10:00:00-05:00`)
|
|
494
|
+
);
|
|
495
|
+
await waitFor(() => editor.shadowRoot?.querySelector("time-picker"));
|
|
496
|
+
|
|
497
|
+
const moved = plans[plans.length - 1];
|
|
498
|
+
expect(moved.date).to.equal(DATE);
|
|
499
|
+
expect(moved.stop_dates).to.deep.equal({ [String(LINDEN)]: NEXT_DATE });
|
|
500
|
+
expect(moved.fixed_first).to.deep.equal({ calendar_event_id: 990 });
|
|
501
|
+
|
|
502
|
+
// The next stop is offered after The Linden on its new day, so it joins it there.
|
|
503
|
+
await waitFor(() => editor.canAddStop);
|
|
504
|
+
editor.shadowRoot?.querySelector<HTMLButtonElement>(".add-stop")?.click();
|
|
505
|
+
const nearby = await waitFor(() =>
|
|
506
|
+
inScheduler<CommunityPicker>(scheduler, ".add-stop-picker community-picker")
|
|
507
|
+
);
|
|
508
|
+
await nearby.updateComplete;
|
|
509
|
+
const cedar = await waitFor(() =>
|
|
510
|
+
Array.from(
|
|
511
|
+
nearby.shadowRoot?.querySelectorAll<HTMLButtonElement>(
|
|
512
|
+
"button.floorplan-image-card"
|
|
513
|
+
) ?? []
|
|
514
|
+
).find((card) => card.textContent?.includes("Cedar & Main"))
|
|
515
|
+
);
|
|
516
|
+
cedar.click();
|
|
517
|
+
await waitFor(() => editor.stops.some((stop) => stop.building_id === CEDAR));
|
|
518
|
+
expect(plans[plans.length - 1].stop_dates).to.deep.equal({
|
|
519
|
+
[String(LINDEN)]: NEXT_DATE,
|
|
520
|
+
[String(CEDAR)]: NEXT_DATE,
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
await submitWhenReady(scheduler);
|
|
524
|
+
await waitFor(() => bookings.length === 2);
|
|
525
|
+
expect(bookings[1].stops).to.deep.equal([
|
|
526
|
+
{ existing_calendar_event_id: 990 },
|
|
527
|
+
{ building_id: LINDEN, start: `${NEXT_DATE}T10:00:00-05:00` },
|
|
528
|
+
{ building_id: CEDAR, start: `${NEXT_DATE}T10:30:00-05:00` },
|
|
529
|
+
]);
|
|
530
|
+
});
|
|
531
|
+
|
|
444
532
|
it("picks one community at a time: a pick replaces the community and opens its schedule", async () => {
|
|
445
533
|
fakeBackend();
|
|
446
534
|
const scheduler = mount();
|