@meetelise/chat 1.70.1 → 1.72.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.
@@ -0,0 +1,108 @@
1
+ import { css, html, LitElement, TemplateResult } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+
4
+ /**
5
+ * A trigger and the small panel it opens, for the v2 scheduler's secondary
6
+ * choices. The panel floats under the trigger with `me-select`'s list surface
7
+ * and closes, as that list does, on a click outside it, or on Escape. With
8
+ * `inline` (phones) it opens in place instead, after its siblings in the
9
+ * parent's flex row, as the filter row always did there.
10
+ *
11
+ * The parent owns `open`; the element asks for a close with `popover-close`.
12
+ * Slot the trigger as `slot="trigger"` and the panel's content in the default
13
+ * slot, so the trigger's `aria-controls` can name an id in the parent's tree.
14
+ */
15
+ @customElement("scheduler-popover")
16
+ export class SchedulerPopover extends LitElement {
17
+ @property({ type: Boolean, reflect: true })
18
+ open = false;
19
+
20
+ @property({ type: Boolean, reflect: true })
21
+ inline = false;
22
+
23
+ connectedCallback(): void {
24
+ super.connectedCallback();
25
+ document.addEventListener("click", this.onDocumentClick);
26
+ this.addEventListener("keydown", this.onKeydown);
27
+ }
28
+
29
+ disconnectedCallback(): void {
30
+ document.removeEventListener("click", this.onDocumentClick);
31
+ this.removeEventListener("keydown", this.onKeydown);
32
+ super.disconnectedCallback();
33
+ }
34
+
35
+ private requestClose(): void {
36
+ this.dispatchEvent(new CustomEvent("popover-close"));
37
+ }
38
+
39
+ /** As `me-select`: a click anywhere outside, trigger included, closes it. */
40
+ private onDocumentClick = (e: MouseEvent): void => {
41
+ if (this.open && !this.inline && !e.composedPath().includes(this)) {
42
+ this.requestClose();
43
+ }
44
+ };
45
+
46
+ private onKeydown = (e: KeyboardEvent): void => {
47
+ if (!this.open || e.key !== "Escape" || e.isComposing) return;
48
+ // The scheduler closes on Escape; here it only closes the panel.
49
+ e.preventDefault();
50
+ e.stopPropagation();
51
+ this.requestClose();
52
+ this.querySelector<HTMLElement>('[slot="trigger"]')?.focus();
53
+ };
54
+
55
+ render(): TemplateResult {
56
+ return html`<slot name="trigger"></slot>
57
+ <div class="panel" ?hidden=${!this.open}><slot></slot></div>`;
58
+ }
59
+
60
+ static styles = css`
61
+ /* New element, from me-select's list surface and the picker's card border. */
62
+ :host {
63
+ display: inline-block;
64
+ position: relative;
65
+ }
66
+
67
+ :host([inline]) {
68
+ display: contents;
69
+ }
70
+
71
+ .panel {
72
+ background-color: #ffffff;
73
+ border: 1px solid #e7e7e7;
74
+ border-radius: 10px;
75
+ box-shadow: 0px 4px 14px rgba(0, 0, 0, 0.15);
76
+ box-sizing: border-box;
77
+ left: 0;
78
+ margin-top: 4px;
79
+ padding: 12px 16px;
80
+ position: absolute;
81
+ top: 100%;
82
+ width: max-content;
83
+ z-index: 20;
84
+ }
85
+
86
+ :host([inline]) .panel {
87
+ background: none;
88
+ border: none;
89
+ box-shadow: none;
90
+ flex-basis: 100%;
91
+ margin-top: 0;
92
+ order: 1;
93
+ padding: 0;
94
+ position: static;
95
+ width: auto;
96
+ }
97
+
98
+ [hidden] {
99
+ display: none;
100
+ }
101
+ `;
102
+ }
103
+
104
+ declare global {
105
+ interface HTMLElementTagNameMap {
106
+ "scheduler-popover": SchedulerPopover;
107
+ }
108
+ }
@@ -102,7 +102,8 @@ export const buildBookingRequest = ({
102
102
  }: {
103
103
  choice: ItineraryChoice;
104
104
  plan: PlanResponse;
105
- contact: BookingContact;
105
+ /** Null when adding stops to a booking: the server already has the prospect. */
106
+ contact: BookingContact | null;
106
107
  attribution: BookingAttribution;
107
108
  conversationTrackingId: string | null;
108
109
  cancelExistingTours: boolean;
@@ -116,7 +117,7 @@ export const buildBookingRequest = ({
116
117
  .filter((stop) => !stop.fixed)
117
118
  .map((stop) => ({ building_id: stop.building_id, start: stop.start })),
118
119
  ],
119
- contact,
120
+ ...(contact ? { contact } : {}),
120
121
  lead_sources: attribution,
121
122
  conversation_tracking_id: conversationTrackingId,
122
123
  cancel_existing_tours: cancelExistingTours,
@@ -8,6 +8,7 @@ import "./contact-form";
8
8
  import "./booking-confirmation";
9
9
  import "../actions/action-confirm-button";
10
10
  import "../loaders/mega-loader";
11
+ import "../mini-loader";
11
12
  import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
12
13
  import { InputStyles } from "../actions/InputStyles";
13
14
  import { ChevronLeftIcon } from "../icons/ChevronLeftIcon";
@@ -28,7 +29,6 @@ import {
28
29
  toCommunitySummary,
29
30
  TourTypeId,
30
31
  } from "./tourItineraryApi";
31
- import { renderSelectionTray, selectionTrayStyles } from "./community-picker";
32
32
  import type { TourTypeChoice, StopProblem } from "./itinerary-editor";
33
33
  import { contactIsValid, ContactValues, EMPTY_CONTACT } from "./contact-form";
34
34
  import type { ConfirmedStop } from "./booking-confirmation";
@@ -139,8 +139,10 @@ export class TourSchedulerV2 extends LitElement {
139
139
  @state() private group: CommunitiesResponse | null = null;
140
140
  @state() private communities = new Map<number, CommunitySummary>();
141
141
  @state() private selectedIds: number[] = [];
142
- /** The open picker's picks, shown in the footer until Continue. */
142
+ /** The picker's pick, marked when the prospect goes back to it. */
143
143
  @state() private picks: CommunitySummary[] = [];
144
+ /** Adding stops: the nearby communities are open under the itinerary. */
145
+ @state() private addingStop = false;
144
146
  @state() private existingEventIds: number[] = [];
145
147
  @state() private tourType: TourTypeId = "escorted-tour";
146
148
  /** A tour type this building books on its own page, once picked. */
@@ -153,6 +155,11 @@ export class TourSchedulerV2 extends LitElement {
153
155
  @state() private planError: string | null = null;
154
156
  @state() private notice: string | null = null;
155
157
  @state() private contact: ContactValues = EMPTY_CONTACT;
158
+ /**
159
+ * Bedrooms, move-in and budget, shared by both pickers' filters and the form
160
+ * (which has no budget) for as long as the widget is open.
161
+ */
162
+ @state() private preferences: CommunityFilters = EMPTY_FILTERS;
156
163
  @state() private submitting = false;
157
164
  @state() private bookingError: string | null = null;
158
165
  @state() private reschedulePrompt: string | null = null;
@@ -236,14 +243,6 @@ export class TourSchedulerV2 extends LitElement {
236
243
  this.foregroundColorOnPrimaryBackgroundColor
237
244
  );
238
245
  }
239
- // A preference picked for communities since swapped out may no longer be offered.
240
- const layout = this.contact.layout;
241
- if (
242
- layout !== null &&
243
- !this.bedroomOptions.some((option) => option.value === layout)
244
- ) {
245
- this.contact = { ...this.contact, layout: null };
246
- }
247
246
  }
248
247
 
249
248
  firstUpdated(): void {
@@ -376,6 +375,9 @@ export class TourSchedulerV2 extends LitElement {
376
375
  * type or date isn't offered, moves to the first one it offers and asks again.
377
376
  */
378
377
  private async runPlan(keepNotice = false): Promise<void> {
378
+ // The nearby list was fetched after the old last stop, without the old
379
+ // stops; "Add another stop" offers it again once this plan is in.
380
+ this.addingStop = false;
379
381
  if (this.selectedIds.length === 0) return;
380
382
  const requestId = ++this.planRequestId;
381
383
  this.planLoading = true;
@@ -636,29 +638,30 @@ export class TourSchedulerV2 extends LitElement {
636
638
 
637
639
  // --- Booking ---
638
640
 
639
- private async submit(
640
- values: ContactValues,
641
- cancelExistingTours = false
642
- ): Promise<void> {
641
+ private async submit(cancelExistingTours = false): Promise<void> {
643
642
  // What's booked, kept apart from the screen, which stays editable while the request runs.
644
643
  const plan = this.plan;
645
644
  if (!plan || this.submitting) return;
646
645
  const choice = this.choice();
646
+ const values = this.formValues;
647
647
  const showDropdown = this.showLeadSourceDropdown();
648
648
  const selectedLeadSource = showDropdown ? values.leadSource : null;
649
649
  const request = buildBookingRequest({
650
650
  choice,
651
651
  plan,
652
- contact: {
653
- first_name: values.firstName.trim(),
654
- last_name: values.lastName.trim(),
655
- email: values.email.trim(),
656
- phone_e164: values.phoneE164 ?? "",
657
- bedrooms:
658
- values.layout === null ? [] : [layoutToBedrooms(values.layout)],
659
- move_in: values.moveIn || null,
660
- notes: values.notes.trim(),
661
- },
652
+ // Adding stops books into the first booking's conversation, so the form isn't shown.
653
+ contact: this.extending
654
+ ? null
655
+ : {
656
+ first_name: values.firstName.trim(),
657
+ last_name: values.lastName.trim(),
658
+ email: values.email.trim(),
659
+ phone_e164: values.phoneE164 ?? "",
660
+ bedrooms:
661
+ values.layout === null ? [] : [layoutToBedrooms(values.layout)],
662
+ move_in: values.moveIn || null,
663
+ notes: values.notes.trim(),
664
+ },
662
665
  attribution: buildAttribution({
663
666
  orgSlug: this.orgSlug,
664
667
  selectedLeadSource,
@@ -699,7 +702,7 @@ export class TourSchedulerV2 extends LitElement {
699
702
  this.rescheduled = cancelExistingTours;
700
703
  this.onBooked(response, choice.tourType, plan);
701
704
  } catch (e) {
702
- this.onBookingError(e, values);
705
+ this.onBookingError(e);
703
706
  } finally {
704
707
  this.submitting = false;
705
708
  }
@@ -788,6 +791,62 @@ export class TourSchedulerV2 extends LitElement {
788
791
  return MAX_ITINERARY_STOPS - this.bookedEventIds.length;
789
792
  }
790
793
 
794
+ /**
795
+ * Another stop fits after the booked ones and those added so far, and the
796
+ * plan shown is for these stops, so the list can start after its last one.
797
+ */
798
+ private get canAddStop(): boolean {
799
+ return (
800
+ !this.planLoading &&
801
+ !this.planError &&
802
+ this.stopsRemaining() > this.selectedIds.length &&
803
+ (this.plan?.stops.length ?? 0) > 0
804
+ );
805
+ }
806
+
807
+ /**
808
+ * As `extendQueryFromBooking`, from the itinerary being added: times after
809
+ * its last planned stop, near it, without any community already in it.
810
+ */
811
+ private extendQueryFromPlan(): ExtendQuery | null {
812
+ const stops = this.plan?.stops ?? [];
813
+ const last = stops[stops.length - 1];
814
+ if (!last || !this.extendFrom) return null;
815
+ return {
816
+ ...this.extendFrom,
817
+ availableAfter: last.end,
818
+ nearBuildingId: last.building_id,
819
+ excludeBuildingIds: [
820
+ ...this.extendFrom.excludeBuildingIds,
821
+ ...this.selectedIds,
822
+ ],
823
+ };
824
+ }
825
+
826
+ private loadAddStopCommunities = (
827
+ filters: CommunityFilters
828
+ ): Promise<CommunitiesResponse> => {
829
+ const extend = this.extendQueryFromPlan();
830
+ if (!extend) return Promise.reject(new Error("No stop to add after"));
831
+ return this.client
832
+ .getCommunities({ ...filters, extend })
833
+ .then(this.rememberPage);
834
+ };
835
+
836
+ /** One more community joins the itinerary, after the stops already in it. */
837
+ private onStopAdded(picked: CommunitySummary[]): void {
838
+ const community = picked[0];
839
+ if (!community) return;
840
+ this.rememberOne(community);
841
+ pushGtmEvent("tourCommunitiesSelected", {
842
+ buildingId: this.buildingId,
843
+ count: 1,
844
+ mode: "extend",
845
+ });
846
+ this.selectedIds = [...this.selectedIds, community.building_id];
847
+ void this.runPlan();
848
+ }
849
+
791
850
  /** Offers more communities while the itinerary has stops left. */
792
851
  private async loadExtension(): Promise<void> {
793
852
  const extend = this.extendQueryFromBooking();
@@ -812,14 +871,13 @@ export class TourSchedulerV2 extends LitElement {
812
871
  }
813
872
  }
814
873
 
815
- private onBookingError(e: unknown, values: ContactValues): void {
874
+ private onBookingError(e: unknown): void {
816
875
  const error =
817
876
  e instanceof TourApiError
818
877
  ? e
819
878
  : new TourApiError(0, null, "Something went wrong. Please try again.");
820
879
  if (error.code === "EXISTING_TOUR") {
821
880
  this.reschedulePrompt = error.message;
822
- this.contact = values;
823
881
  return;
824
882
  }
825
883
  this.reschedulePrompt = null;
@@ -893,7 +951,7 @@ export class TourSchedulerV2 extends LitElement {
893
951
  plan.stops.some((s) => !s.fixed) &&
894
952
  plan.unchainable.length === 0 &&
895
953
  this.activeLinkType === null &&
896
- contactIsValid(this.contact, this.bedroomsRequired)
954
+ (this.extending || contactIsValid(this.formValues, this.bedroomsRequired))
897
955
  );
898
956
  }
899
957
 
@@ -904,16 +962,57 @@ export class TourSchedulerV2 extends LitElement {
904
962
  * building's layouts.
905
963
  */
906
964
  private get bedroomOptions(): LayoutOption[] {
907
- const toured = [
908
- ...(this.extending ? this.confirmed.map((stop) => stop.community) : []),
909
- ...this.selectedIds.map((id) => this.communities.get(id)),
910
- ];
911
- const counts = new Set(toured.flatMap((c) => c?.bedrooms ?? []));
965
+ const counts = new Set(
966
+ this.selectedIds.flatMap((id) => this.communities.get(id)?.bedrooms ?? [])
967
+ );
912
968
  return counts.size > 0
913
969
  ? [...counts].sort((a, b) => a - b).map(bedroomsToLayoutOption)
914
970
  : this.layoutOptions;
915
971
  }
916
972
 
973
+ /**
974
+ * The form's bedroom preference, from the shared bedrooms: the one offered
975
+ * option they name, or none when they name no offered option or several.
976
+ */
977
+ private get preferredLayout(): number | null {
978
+ const named = this.bedroomOptions.filter((option) =>
979
+ this.preferences.bedrooms.includes(layoutToBedrooms(option.value))
980
+ );
981
+ return named.length === 1 ? named[0].value : null;
982
+ }
983
+
984
+ /** The form's values, with bedrooms and move-in from the shared preferences. */
985
+ private get formValues(): ContactValues {
986
+ return {
987
+ ...this.contact,
988
+ layout: this.preferredLayout,
989
+ moveIn: this.preferences.moveIn ?? "",
990
+ };
991
+ }
992
+
993
+ private onContactChange(values: ContactValues): void {
994
+ this.contact = values;
995
+ // Every edit sends the whole form: only a field the prospect changed replaces
996
+ // the shared value, so typing a name keeps bedrooms the form can't show.
997
+ const shown = this.formValues;
998
+ if (values.layout !== shown.layout) {
999
+ this.preferences = {
1000
+ ...this.preferences,
1001
+ bedrooms:
1002
+ values.layout === null ? [] : [layoutToBedrooms(values.layout)],
1003
+ };
1004
+ }
1005
+ if (values.moveIn !== shown.moveIn) {
1006
+ this.preferences = { ...this.preferences, moveIn: values.moveIn || null };
1007
+ }
1008
+ }
1009
+
1010
+ private onFiltersChange = (
1011
+ e: CustomEvent<{ filters: CommunityFilters }>
1012
+ ): void => {
1013
+ this.preferences = e.detail.filters;
1014
+ };
1015
+
917
1016
  /** A preference can only be required where there is one to choose. */
918
1017
  private get bedroomsRequired(): boolean {
919
1018
  return this.bedroomPreferenceRequired && this.bedroomOptions.length > 0;
@@ -950,28 +1049,46 @@ export class TourSchedulerV2 extends LitElement {
950
1049
  variant="select"
951
1050
  .load=${this.loadSelectCommunities}
952
1051
  .initial=${this.group}
953
- .maxSelectable=${1}
1052
+ .filters=${this.preferences}
954
1053
  .selected=${this.picks}
1054
+ @filters-change=${this.onFiltersChange}
955
1055
  @selection-change=${(
956
1056
  e: CustomEvent<{ communities: CommunitySummary[] }>
957
1057
  ) => this.onCommunitiesSelected(e.detail.communities, "select")}
958
1058
  ></community-picker>`);
959
1059
  }
960
1060
 
961
- private onPicksChange = (
962
- e: CustomEvent<{ communities: CommunitySummary[] }>
963
- ): void => {
964
- this.picks = e.detail.communities;
965
- };
1061
+ /** Adding stops to a booking: the design's itinerary heading. */
1062
+ private renderItineraryHeading(): TemplateResult {
1063
+ return html`<div class="itinerary-heading">
1064
+ <h2>
1065
+ Create Your Tour Itinerary
1066
+ ${this.planLoading ? html`<mini-loader></mini-loader>` : ""}
1067
+ </h2>
1068
+ <p class="explanation">Add up to ${MAX_ITINERARY_STOPS} communities</p>
1069
+ </div>`;
1070
+ }
966
1071
 
967
- private renderTray(): TemplateResult | string {
968
- return renderSelectionTray({
969
- selected: this.picks,
970
- mobile: this.mobile,
971
- onRemove: (buildingId) =>
972
- (this.picks = this.picks.filter((c) => c.building_id !== buildingId)),
973
- onContinue: () => this.onCommunitiesSelected(this.picks, "extend"),
974
- });
1072
+ /** "Add another stop": the nearby communities, under the itinerary. */
1073
+ private renderAddStop(): TemplateResult {
1074
+ return html`<div class="add-stop-picker">
1075
+ <button
1076
+ class="close-add-stop"
1077
+ aria-label="Close nearby communities"
1078
+ @click=${() => (this.addingStop = false)}
1079
+ >
1080
+ ${XOutlineIcon("#737373")}
1081
+ </button>
1082
+ <community-picker
1083
+ variant="extend"
1084
+ .load=${this.loadAddStopCommunities}
1085
+ .filters=${this.preferences}
1086
+ @filters-change=${this.onFiltersChange}
1087
+ @selection-change=${(
1088
+ e: CustomEvent<{ communities: CommunitySummary[] }>
1089
+ ) => this.onStopAdded(e.detail.communities)}
1090
+ ></community-picker>
1091
+ </div>`;
975
1092
  }
976
1093
 
977
1094
  private renderSchedule(): TemplateResult {
@@ -986,10 +1103,14 @@ export class TourSchedulerV2 extends LitElement {
986
1103
  </button>
987
1104
  </p>`
988
1105
  : ""}
1106
+ ${this.extending ? this.renderItineraryHeading() : ""}
989
1107
  ${this.notice
990
1108
  ? html`<p class="explanation notice" role="status">${this.notice}</p>`
991
1109
  : ""}
992
- <div id="book-tour-journey-items">
1110
+ <div
1111
+ id="book-tour-journey-items"
1112
+ class=${classMap({ itinerary: this.extending })}
1113
+ >
993
1114
  <itinerary-editor
994
1115
  .stops=${plan?.stops ?? []}
995
1116
  .communities=${this.communities}
@@ -999,6 +1120,8 @@ export class TourSchedulerV2 extends LitElement {
999
1120
  .bookableDates=${plan?.bookable_dates ?? []}
1000
1121
  .date=${this.date}
1001
1122
  ?single=${!this.isMultiStop()}
1123
+ ?stopsOnly=${this.extending}
1124
+ ?canAddStop=${this.extending && !this.addingStop && this.canAddStop}
1002
1125
  ?canEditCommunities=${this.group !== null && !this.extending}
1003
1126
  ?loading=${this.planLoading}
1004
1127
  ?planned=${plan !== null}
@@ -1017,27 +1140,33 @@ export class TourSchedulerV2 extends LitElement {
1017
1140
  @stop-remove=${(e: CustomEvent<{ buildingId: number }>) =>
1018
1141
  this.onRemove(e.detail.buildingId)}
1019
1142
  @edit-communities=${() => this.onEditCommunities()}
1143
+ @add-stop=${() => (this.addingStop = true)}
1020
1144
  @open-tour-link=${() =>
1021
1145
  this.activeLinkType && this.openTourLink(this.activeLinkType)}
1022
1146
  ></itinerary-editor>
1023
- <contact-form
1024
- .values=${this.contact}
1025
- .layoutOptions=${this.bedroomOptions}
1026
- ?bedroomsRequired=${this.bedroomsRequired}
1027
- .leadSources=${this.leadSources}
1028
- ?showLeadSourceDropdown=${this.showLeadSourceDropdown()}
1029
- currentLeadSource=${this.currentLeadSource}
1030
- .country=${this.country}
1031
- ?mobile=${this.mobile}
1032
- @contact-change=${(e: CustomEvent<{ values: ContactValues }>) =>
1033
- (this.contact = e.detail.values)}
1034
- @lead-source-selected=${(e: CustomEvent<{ leadSource: string }>) =>
1035
- pushGtmEvent("tourLeadSourceSelected", {
1036
- leadSource: e.detail.leadSource,
1037
- buildingId: this.buildingId,
1038
- })}
1039
- ></contact-form>
1147
+ ${this.extending
1148
+ ? ""
1149
+ : html`<contact-form
1150
+ .values=${this.formValues}
1151
+ .layoutOptions=${this.bedroomOptions}
1152
+ ?bedroomsRequired=${this.bedroomsRequired}
1153
+ .leadSources=${this.leadSources}
1154
+ ?showLeadSourceDropdown=${this.showLeadSourceDropdown()}
1155
+ currentLeadSource=${this.currentLeadSource}
1156
+ .country=${this.country}
1157
+ ?mobile=${this.mobile}
1158
+ @contact-change=${(e: CustomEvent<{ values: ContactValues }>) =>
1159
+ this.onContactChange(e.detail.values)}
1160
+ @lead-source-selected=${(
1161
+ e: CustomEvent<{ leadSource: string }>
1162
+ ) =>
1163
+ pushGtmEvent("tourLeadSourceSelected", {
1164
+ leadSource: e.detail.leadSource,
1165
+ buildingId: this.buildingId,
1166
+ })}
1167
+ ></contact-form>`}
1040
1168
  </div>
1169
+ ${this.extending && this.addingStop ? this.renderAddStop() : ""}
1041
1170
  `)}
1042
1171
  <div
1043
1172
  id="tour-scheduler-footer"
@@ -1055,11 +1184,15 @@ export class TourSchedulerV2 extends LitElement {
1055
1184
  </div>
1056
1185
  <action-confirm-button
1057
1186
  id="schedule-bttn"
1058
- .onClick=${() => this.submit(this.contact)}
1187
+ .onClick=${() => this.submit()}
1059
1188
  .isLoading=${this.submitting}
1060
1189
  height="50px"
1061
- width=${this.mobile ? "100%" : "145px"}
1062
- text=${this.isMultiStop() ? "Schedule tours" : "Schedule tour"}
1190
+ width=${this.mobile ? "100%" : this.extending ? "200px" : "145px"}
1191
+ text=${this.extending
1192
+ ? "Confirm tour itinerary"
1193
+ : this.isMultiStop()
1194
+ ? "Schedule tours"
1195
+ : "Schedule tour"}
1063
1196
  ?disabled=${!this.canSubmit()}
1064
1197
  ></action-confirm-button>
1065
1198
  </div>`;
@@ -1091,7 +1224,7 @@ export class TourSchedulerV2 extends LitElement {
1091
1224
  ></action-confirm-button>
1092
1225
  <action-confirm-button
1093
1226
  id="reschedule-button"
1094
- .onClick=${() => this.submit(this.contact, true)}
1227
+ .onClick=${() => this.submit(true)}
1095
1228
  .isLoading=${this.submitting}
1096
1229
  height="50px"
1097
1230
  width="145px"
@@ -1120,13 +1253,14 @@ export class TourSchedulerV2 extends LitElement {
1120
1253
  variant="extend"
1121
1254
  .load=${this.loadExtendCommunities}
1122
1255
  .initial=${this.extendInitial}
1123
- .maxSelectable=${this.stopsRemaining()}
1124
- .selected=${this.picks}
1125
- @selection-change=${this.onPicksChange}
1256
+ .filters=${this.preferences}
1257
+ @filters-change=${this.onFiltersChange}
1258
+ @selection-change=${(
1259
+ e: CustomEvent<{ communities: CommunitySummary[] }>
1260
+ ) => this.onCommunitiesSelected(e.detail.communities, "extend")}
1126
1261
  ></community-picker>`
1127
1262
  : ""}
1128
- </booking-confirmation>`)}
1129
- ${this.extendInitial ? this.renderTray() : ""}`;
1263
+ </booking-confirmation>`)}`;
1130
1264
  }
1131
1265
 
1132
1266
  private renderBody(): TemplateResult {
@@ -1194,7 +1328,6 @@ export class TourSchedulerV2 extends LitElement {
1194
1328
  static styles = [
1195
1329
  tourSchedulerStyles,
1196
1330
  InputStyles,
1197
- selectionTrayStyles,
1198
1331
  css`
1199
1332
  /* New layout only: the back button beside the title. */
1200
1333
  .title {
@@ -1224,6 +1357,45 @@ export class TourSchedulerV2 extends LitElement {
1224
1357
  margin: 0 0 16px;
1225
1358
  }
1226
1359
 
1360
+ /* Adding stops: the design's one centred column of stops. */
1361
+ #book-tour-journey-items.itinerary {
1362
+ display: block;
1363
+ margin: 0 auto;
1364
+ max-width: 30rem;
1365
+ }
1366
+
1367
+ .itinerary-heading {
1368
+ margin-bottom: 16px;
1369
+ text-align: center;
1370
+ }
1371
+
1372
+ /* The pickers' heading size. */
1373
+ .itinerary-heading h2 {
1374
+ align-items: center;
1375
+ display: flex;
1376
+ font-size: 20px;
1377
+ font-weight: 400;
1378
+ gap: 8px;
1379
+ justify-content: center;
1380
+ margin: 0;
1381
+ }
1382
+
1383
+ .add-stop-picker {
1384
+ margin-top: 24px;
1385
+ position: relative;
1386
+ }
1387
+
1388
+ /* The extend picker's top rule and padding put its heading 24px down. */
1389
+ .close-add-stop {
1390
+ background: none;
1391
+ border: none;
1392
+ cursor: pointer;
1393
+ padding: 4px;
1394
+ position: absolute;
1395
+ right: 0;
1396
+ top: 24px;
1397
+ }
1398
+
1227
1399
  .link-button {
1228
1400
  background: none;
1229
1401
  border: none;
@@ -150,7 +150,8 @@ export interface BookingAttribution {
150
150
  export interface BookingRequest {
151
151
  tour_type: TourTypeId;
152
152
  stops: BookingStopRequest[];
153
- contact: BookingContact;
153
+ /** Left out when adding stops to a booking, which books into its conversation. */
154
+ contact?: BookingContact;
154
155
  lead_sources: BookingAttribution;
155
156
  conversation_tracking_id: string | null;
156
157
  cancel_existing_tours: boolean;
@@ -127,6 +127,13 @@ const fakeBackend = (options: FakeBackendOptions = {}): FakeRequest[] => {
127
127
  }
128
128
  return json(200, session);
129
129
  }
130
+ // Today's scheduler, when it opens, asks for its availabilities.
131
+ if (url.includes("/tour/availabilities")) {
132
+ return json(200, {
133
+ availability: {},
134
+ rankOrderedSupportedTourTypes: [],
135
+ });
136
+ }
130
137
  if (url.includes("chat-ui-feature-flag")) return json(200, false);
131
138
  return json(200, null);
132
139
  });