@meetelise/chat 1.71.0 → 1.73.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.
@@ -41,6 +41,9 @@ import {
41
41
  FeatureFlagsShowDropdown,
42
42
  fetchTrackedRolloutCoastalCustomTourTypes,
43
43
  } from "../../fetchFeatureFlag";
44
+ import fetchFloorplanOptions, {
45
+ FloorplanOption,
46
+ } from "../../fetchFloorplanOptions";
44
47
  import {
45
48
  appendParamsToUrl,
46
49
  getUrlQueryParameters,
@@ -284,6 +287,8 @@ export class TourScheduler extends LitElement {
284
287
  selectedLeadSource!: MESelect;
285
288
  @query("me-select#layout")
286
289
  selectedLayoutEl?: MESelect;
290
+ @query("me-select#floorplan")
291
+ selectedFloorplanEl?: MESelect;
287
292
  @query("me-select#unit")
288
293
  selectedUnitEl?: MESelect;
289
294
 
@@ -295,6 +300,11 @@ export class TourScheduler extends LitElement {
295
300
  leadSourceInputValue = "";
296
301
  @state()
297
302
  selectedLayoutValue = "";
303
+ /** Filled when the building is on the WEBCHAT_FLOORPLAN_PREFERENCE switch; the floor plan dropdown then replaces the bedroom one. */
304
+ @state()
305
+ floorplanOptions: FloorplanOption[] = [];
306
+ @state()
307
+ selectedFloorplanName = "";
298
308
  @state()
299
309
  selectedUnitValue = "";
300
310
  @state()
@@ -583,6 +593,7 @@ export class TourScheduler extends LitElement {
583
593
  const useCoastalCustomTourTypes = fetchTrackedRolloutCoastalCustomTourTypes(
584
594
  this.buildingSlug
585
595
  );
596
+ const floorplanOptions = fetchFloorplanOptions(this.buildingSlug);
586
597
  this.tourTypeOrder = tourTypeOrderFor(
587
598
  await getRawAvailabilities(this.buildingId).then(
588
599
  (availabilities) => availabilities.rankOrderedSupportedTourTypes ?? [],
@@ -590,6 +601,7 @@ export class TourScheduler extends LitElement {
590
601
  )
591
602
  );
592
603
  this.useCoastalCustomTourTypes = await useCoastalCustomTourTypes;
604
+ this.floorplanOptions = await floorplanOptions;
593
605
  await Promise.all([
594
606
  this._setAvailabilities().then(async () => {
595
607
  try {
@@ -635,6 +647,8 @@ export class TourScheduler extends LitElement {
635
647
  this.mobilePageIndex = 0;
636
648
  this.units = [];
637
649
  this.selectedLayoutValue = "";
650
+ this.floorplanOptions = [];
651
+ this.selectedFloorplanName = "";
638
652
  this.selectedUnitValue = "";
639
653
 
640
654
  this.buildingId = building.building_id;
@@ -818,7 +832,9 @@ export class TourScheduler extends LitElement {
818
832
  );
819
833
  },
820
834
  layout: (): boolean =>
821
- !this.bedroomPreferenceRequired || !!this.selectedLayoutValue,
835
+ !this.bedroomPreferenceRequired ||
836
+ !!this.selectedLayoutValue ||
837
+ !!this.selectedFloorplanName,
822
838
  broker: (): boolean => {
823
839
  const broker = this.brokerReferral();
824
840
  // The broker's phone is optional, but one that's been typed has to be valid.
@@ -941,6 +957,9 @@ export class TourScheduler extends LitElement {
941
957
  query_params: Object.fromEntries(queryParams.entries()),
942
958
  conversation_tracking_id: this.leadSourceClient?.chatId,
943
959
  layouts: selectedLayout ? [selectedLayout] : undefined,
960
+ floorplans: this.selectedFloorplanName
961
+ ? [this.selectedFloorplanName]
962
+ : undefined,
944
963
  unit_numbers: selectedUnit ? [selectedUnit] : undefined,
945
964
  lead_sources_with_timestamps: (
946
965
  this.leadSourceMultitouchClient?.getSafeLeadSourceTouchpointsWithDefault(
@@ -1544,6 +1563,29 @@ export class TourScheduler extends LitElement {
1544
1563
  );
1545
1564
  }
1546
1565
 
1566
+ /** Sets the canonical layout ("studio", "1br", ...) picked from the bedroom or floor plan dropdown. */
1567
+ private selectLayout = (v: string): void => {
1568
+ this.selectedLayoutValue = v;
1569
+ // Clear unit selection if it no longer matches the new layout.
1570
+ if (v && this.selectedUnitValue) {
1571
+ const unit = this.units.find(
1572
+ (u) => u.unitNumber === this.selectedUnitValue
1573
+ );
1574
+ if (unit && layoutValueToCanonical(unit.numberOfBedrooms * 10) !== v) {
1575
+ this.selectedUnitValue = "";
1576
+ if (this.selectedUnitEl) {
1577
+ this.selectedUnitEl.value = undefined;
1578
+ }
1579
+ }
1580
+ }
1581
+ if (v) {
1582
+ pushGtmEvent("tourLayoutSelected", {
1583
+ layout: v,
1584
+ buildingId: this.buildingId,
1585
+ });
1586
+ }
1587
+ };
1588
+
1547
1589
  userInfoAndLayoutMenu(): TemplateResult {
1548
1590
  const isReferral = this.brokerIntakeEnabled && this.isBrokerReferral;
1549
1591
  return html`<h2 class="journey-header">Your Information</h2>
@@ -1626,7 +1668,30 @@ export class TourScheduler extends LitElement {
1626
1668
  ${this.brokerIntakeEnabled && !isReferral
1627
1669
  ? this.renderBrokerToggle()
1628
1670
  : ""}
1629
- ${this.layoutOptions.length > 0
1671
+ ${this.floorplanOptions.length > 0
1672
+ ? html` <me-select
1673
+ id="floorplan"
1674
+ placeholder=${this.bedroomPreferenceRequired
1675
+ ? "Floor plan preference"
1676
+ : "Floor plan preference (optional)"}
1677
+ .value=${this.selectedFloorplanName}
1678
+ .options="${this.floorplanOptions.map((o) => ({
1679
+ label: o.name,
1680
+ value: o.name,
1681
+ }))}"
1682
+ @change=${() => {
1683
+ const name = this.selectedFloorplanEl?.value || "";
1684
+ const bedrooms = this.floorplanOptions.find(
1685
+ (o) => o.name === name
1686
+ )?.bedrooms;
1687
+ this.selectedFloorplanName = name;
1688
+ this.selectLayout(
1689
+ bedrooms == null ? "" : layoutValueToCanonical(bedrooms * 10)
1690
+ );
1691
+ }}
1692
+ >
1693
+ </me-select>`
1694
+ : this.layoutOptions.length > 0
1630
1695
  ? html` <me-select
1631
1696
  id="layout"
1632
1697
  placeholder=${this.bedroomPreferenceRequired
@@ -1636,31 +1701,8 @@ export class TourScheduler extends LitElement {
1636
1701
  label: o.label,
1637
1702
  value: layoutValueToCanonical(o.value),
1638
1703
  }))}"
1639
- @change=${() => {
1640
- const v = this.selectedLayoutEl?.value || "";
1641
- this.selectedLayoutValue = v;
1642
- // Clear unit selection if it no longer matches the new layout.
1643
- if (v && this.selectedUnitValue) {
1644
- const unit = this.units.find(
1645
- (u) => u.unitNumber === this.selectedUnitValue
1646
- );
1647
- if (
1648
- unit &&
1649
- layoutValueToCanonical(unit.numberOfBedrooms * 10) !== v
1650
- ) {
1651
- this.selectedUnitValue = "";
1652
- if (this.selectedUnitEl) {
1653
- this.selectedUnitEl.value = undefined;
1654
- }
1655
- }
1656
- }
1657
- if (v) {
1658
- pushGtmEvent("tourLayoutSelected", {
1659
- layout: v,
1660
- buildingId: this.buildingId,
1661
- });
1662
- }
1663
- }}
1704
+ @change=${() =>
1705
+ this.selectLayout(this.selectedLayoutEl?.value || "")}
1664
1706
  >
1665
1707
  </me-select>`
1666
1708
  : ""}
@@ -2,14 +2,12 @@ import { css, html, LitElement, TemplateResult } from "lit";
2
2
  import { customElement, property, state } from "lit/decorators.js";
3
3
  import { classMap } from "lit/directives/class-map.js";
4
4
  import "../actions/action-confirm-button";
5
- import "../shared/simple-tooltip";
6
5
  import "./scheduler-popover";
7
6
  import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
8
7
  import { InputStyles } from "../actions/InputStyles";
9
8
  import floorplanImageCardStyles from "../FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles";
10
9
  import floorPlanSelectorStyles from "../FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles";
11
10
  import { BuildingIcon } from "../icons/BuildingIcon";
12
- import { XOutlineIcon } from "../icons/XOutlineIcon";
13
11
  import {
14
12
  CommunitiesResponse,
15
13
  Community,
@@ -43,11 +41,10 @@ type FilterId = "bedrooms" | "moveIn" | "budget";
43
41
  const FILTER_IDS: FilterId[] = ["bedrooms", "moveIn", "budget"];
44
42
 
45
43
  /**
46
- * Lists a central group's top communities so the prospect can pick one, or, in
47
- * the "extend" variant after a booking, up to the number of stops left. Ranking
48
- * and every reason come from the server. The cards and badges are the fee
49
- * calculator's. The scheduler holds the picks; after a booking it shows them,
50
- * with Continue, in its footer (`renderSelectionTray`).
44
+ * Lists a central group's top communities so the prospect can pick one: the
45
+ * community to tour, or, in the "extend" variant after a booking, the next stop
46
+ * to add. Ranking and every reason come from the server. The cards and badges
47
+ * are the fee calculator's.
51
48
  */
52
49
  @customElement("community-picker")
53
50
  export class CommunityPicker extends LitElement {
@@ -61,14 +58,10 @@ export class CommunityPicker extends LitElement {
61
58
  @property({ attribute: false })
62
59
  initial: CommunitiesResponse | null = null;
63
60
 
64
- /** The picks so far; a click asks for a change with `selection-change`. */
61
+ /** The pick so far, if any; a click asks for a change with `selection-change`. */
65
62
  @property({ attribute: false })
66
63
  selected: CommunitySummary[] = [];
67
64
 
68
- /** How many communities may be picked: the stops left in the itinerary. */
69
- @property({ type: Number })
70
- maxSelectable = 0;
71
-
72
65
  /**
73
66
  * The prospect's filters, which the scheduler shares with its form for this
74
67
  * visit; a change is reported with `filters-change`.
@@ -148,15 +141,7 @@ export class CommunityPicker extends LitElement {
148
141
  private toggle(community: Community): void {
149
142
  if (!community.tourable) return;
150
143
  // One to pick: a click picks it, in place of any earlier pick.
151
- if (this.maxSelectable === 1) {
152
- this.emitSelection([toCommunitySummary(community)]);
153
- } else if (this.isSelected(community.building_id)) {
154
- this.emitSelection(
155
- this.selected.filter((s) => s.building_id !== community.building_id)
156
- );
157
- } else if (this.selected.length < this.maxSelectable) {
158
- this.emitSelection([...this.selected, toCommunitySummary(community)]);
159
- }
144
+ this.emitSelection([toCommunitySummary(community)]);
160
145
  }
161
146
 
162
147
  private emitSelection(communities: CommunitySummary[]): void {
@@ -170,11 +155,8 @@ export class CommunityPicker extends LitElement {
170
155
  }
171
156
 
172
157
  private heading(): string {
173
- if (this.variant === "extend") {
174
- return "Add Nearby Communities to Your Tour";
175
- }
176
- return this.maxSelectable > 1
177
- ? `Select Up to ${this.maxSelectable} Communities to Tour`
158
+ return this.variant === "extend"
159
+ ? "Add Nearby Communities to Your Tour"
178
160
  : "Select a Community to Tour";
179
161
  }
180
162
 
@@ -316,10 +298,6 @@ export class CommunityPicker extends LitElement {
316
298
 
317
299
  private renderCard(c: Community): TemplateResult {
318
300
  const selected = this.isSelected(c.building_id);
319
- const full =
320
- this.maxSelectable > 1 &&
321
- !selected &&
322
- this.selected.length >= this.maxSelectable;
323
301
  const next = c.next_available;
324
302
  // Extension times are all on the day already booked.
325
303
  const sameDay = !!next && this.variant === "extend";
@@ -328,61 +306,55 @@ export class CommunityPicker extends LitElement {
328
306
  c.price_from.bedrooms === 0 ? "Studio" : `${c.price_from.bedrooms} BR`
329
307
  } from ${formatCurrency(c.price_from.amount)}`
330
308
  : "";
331
- const card = html`<button
332
- class=${classMap({
333
- "floorplan-image-card": true,
334
- selected,
335
- disabled: !c.tourable || full,
336
- })}
337
- aria-pressed=${String(selected)}
338
- aria-disabled=${String(!c.tourable || full)}
339
- @click=${() => this.toggle(c)}
340
- >
341
- ${c.image_url
342
- ? html`<span class="section-left"
343
- ><img src=${c.image_url} alt=""
344
- /></span>`
345
- : ""}
346
- <span class="section-right">
347
- ${c.best_match || price || c.distance_mi !== null
348
- ? html`<span class="card-tags">
349
- ${c.best_match
350
- ? html`<span class="floor-plan-badge">Best match</span>`
351
- : ""}
352
- ${price
353
- ? html`<span class="floor-plan-badge">${price}</span>`
354
- : ""}
355
- ${c.distance_mi !== null
356
- ? html`<span class="distance"
357
- >${c.distance_mi.toFixed(1)} mi</span
358
- >`
359
- : ""}
360
- </span>`
361
- : ""}
362
- <span class="image-card-title">${c.name}</span>
363
- <span class="image-card-subtitle">${formatAddress(c.address)}</span>
364
- ${!c.tourable
365
- ? html`<span class="image-card-subtitle"
366
- >${c.unavailable_reason ?? ""}</span
367
- >`
368
- : next
369
- ? html`<span class="next-available"
370
- >Next available:
371
- ${formatShortDate(next.date)}${this.variant === "extend"
372
- ? ` · ${formatHourMinute(next.time)}`
373
- : ""}</span
374
- >`
375
- : ""}
376
- ${sameDay ? html`<span class="same-day">Same day</span>` : ""}
377
- </span>
378
- </button>`;
379
309
  return html`<li>
380
- ${full && c.tourable
381
- ? html`<simple-tooltip
382
- tooltip=${`You can choose up to ${this.maxSelectable}`}
383
- >${card}</simple-tooltip
384
- >`
385
- : card}
310
+ <button
311
+ class=${classMap({
312
+ "floorplan-image-card": true,
313
+ selected,
314
+ disabled: !c.tourable,
315
+ })}
316
+ aria-pressed=${String(selected)}
317
+ aria-disabled=${String(!c.tourable)}
318
+ @click=${() => this.toggle(c)}
319
+ >
320
+ ${c.image_url
321
+ ? html`<span class="section-left"
322
+ ><img src=${c.image_url} alt=""
323
+ /></span>`
324
+ : ""}
325
+ <span class="section-right">
326
+ ${c.best_match || price || c.distance_mi !== null
327
+ ? html`<span class="card-tags">
328
+ ${c.best_match
329
+ ? html`<span class="floor-plan-badge">Best match</span>`
330
+ : ""}
331
+ ${price
332
+ ? html`<span class="floor-plan-badge">${price}</span>`
333
+ : ""}
334
+ ${c.distance_mi !== null
335
+ ? html`<span class="distance"
336
+ >${c.distance_mi.toFixed(1)} mi</span
337
+ >`
338
+ : ""}
339
+ </span>`
340
+ : ""}
341
+ <span class="image-card-title">${c.name}</span>
342
+ <span class="image-card-subtitle">${formatAddress(c.address)}</span>
343
+ ${!c.tourable
344
+ ? html`<span class="image-card-subtitle"
345
+ >${c.unavailable_reason ?? ""}</span
346
+ >`
347
+ : next
348
+ ? html`<span class="next-available"
349
+ >Next available:
350
+ ${formatShortDate(next.date)}${this.variant === "extend"
351
+ ? ` · ${formatHourMinute(next.time)}`
352
+ : ""}</span
353
+ >`
354
+ : ""}
355
+ ${sameDay ? html`<span class="same-day">Same day</span>` : ""}
356
+ </span>
357
+ </button>
386
358
  </li>`;
387
359
  }
388
360
 
@@ -627,97 +599,6 @@ export class CommunityPicker extends LitElement {
627
599
  ];
628
600
  }
629
601
 
630
- /**
631
- * The picks and Continue, in the scheduler's footer under either picker. The
632
- * scheduler renders it so the footer stays its own, as on every other step.
633
- */
634
- export const renderSelectionTray = ({
635
- selected,
636
- mobile,
637
- onRemove,
638
- onContinue,
639
- }: {
640
- selected: CommunitySummary[];
641
- mobile: boolean;
642
- onRemove: (buildingId: number) => void;
643
- onContinue: () => void;
644
- }): TemplateResult | string =>
645
- selected.length === 0
646
- ? ""
647
- : html`<div
648
- id="tour-scheduler-footer"
649
- class=${classMap({ tray: true, stacked: mobile })}
650
- >
651
- <ul
652
- class="floor-plan-selector-badges"
653
- aria-label="Selected communities"
654
- >
655
- ${selected.map(
656
- (s) => html`<li class="floor-plan-badge">
657
- ${s.name}
658
- <button
659
- class="remove"
660
- aria-label=${`Remove ${s.name}`}
661
- @click=${() => onRemove(s.building_id)}
662
- >
663
- ${XOutlineIcon("#737373")}
664
- </button>
665
- </li>`
666
- )}
667
- </ul>
668
- <action-confirm-button
669
- id="continue-bttn"
670
- text="Continue"
671
- height="50px"
672
- width=${mobile ? "100%" : "145px"}
673
- .onClick=${onContinue}
674
- ></action-confirm-button>
675
- </div>`;
676
-
677
- /**
678
- * Styles for `renderSelectionTray`: the fee calculator's badges (its padding and
679
- * radius), without the rest of its stylesheet, which also styles `:host`.
680
- */
681
- export const selectionTrayStyles = css`
682
- .tray {
683
- gap: 12px;
684
- }
685
-
686
- .tray .floor-plan-selector-badges {
687
- display: flex;
688
- flex-wrap: wrap;
689
- gap: 8px;
690
- list-style: none;
691
- margin: 0;
692
- padding: 0;
693
- }
694
-
695
- .tray .floor-plan-badge {
696
- align-items: center;
697
- background: #f3f3f3;
698
- border: 1px solid #e7e7e7;
699
- border-radius: 16px;
700
- display: inline-flex;
701
- font-size: 13px;
702
- gap: 6px;
703
- padding: 6px 12px;
704
- white-space: nowrap;
705
- }
706
-
707
- .remove {
708
- background: none;
709
- border: none;
710
- cursor: pointer;
711
- display: inline-flex;
712
- padding: 0;
713
- }
714
-
715
- .remove svg {
716
- height: 9px;
717
- width: 9px;
718
- }
719
- `;
720
-
721
602
  declare global {
722
603
  interface HTMLElementTagNameMap {
723
604
  "community-picker": CommunityPicker;
@@ -105,6 +105,14 @@ export class ItineraryEditor extends LitElement {
105
105
  @property({ type: Boolean })
106
106
  canEditCommunities = false;
107
107
 
108
+ /** Adding stops to a booking: only the stops, as the design's itinerary. */
109
+ @property({ type: Boolean })
110
+ stopsOnly = false;
111
+
112
+ /** With `stopsOnly`, the itinerary has room for another stop. */
113
+ @property({ type: Boolean })
114
+ canAddStop = false;
115
+
108
116
  @property({ type: Boolean })
109
117
  loading = false;
110
118
 
@@ -198,10 +206,11 @@ export class ItineraryEditor extends LitElement {
198
206
  </div>
199
207
  ${this.canEditCommunities
200
208
  ? html`<button
201
- class="floor-plan-badge"
209
+ class="icon-button change-community"
210
+ aria-label="Change community"
202
211
  @click=${() => emit(this, "edit-communities", {})}
203
212
  >
204
- Change
213
+ ${PencilIcon()}
205
214
  </button>`
206
215
  : ""}
207
216
  </div> `;
@@ -421,7 +430,8 @@ export class ItineraryEditor extends LitElement {
421
430
  </button>`}
422
431
  ${editing ? this.renderTimePicker(stop) : ""}
423
432
  </div>
424
- ${!stop.fixed && (ids.length > 1 || this.problems.length > 0)
433
+ ${!stop.fixed &&
434
+ (ids.length > 1 || this.problems.length > 0 || this.stopsOnly)
425
435
  ? this.renderRemove(stop.building_id, community?.name ?? "")
426
436
  : ""}
427
437
  </div>
@@ -463,17 +473,32 @@ export class ItineraryEditor extends LitElement {
463
473
  : ""}`;
464
474
  }
465
475
 
476
+ private renderStops(): TemplateResult {
477
+ return html`<ol class="stops" aria-busy=${String(this.loading)}>
478
+ ${this.stops.map((stop, i) => this.renderStop(stop, i))}
479
+ ${this.problems.map((p) => this.renderProblem(p))}
480
+ </ol>`;
481
+ }
482
+
466
483
  private renderItinerary(): TemplateResult {
467
484
  return html`<h2 class="journey-header">
468
485
  Your Itinerary ${this.loading ? html`<mini-loader></mini-loader>` : ""}
469
486
  </h2>
470
- <ol class="stops" aria-busy=${String(this.loading)}>
471
- ${this.stops.map((stop, i) => this.renderStop(stop, i))}
472
- ${this.problems.map((p) => this.renderProblem(p))}
473
- </ol>`;
487
+ ${this.renderStops()}`;
474
488
  }
475
489
 
476
490
  render(): TemplateResult {
491
+ if (this.stopsOnly) {
492
+ return html`${this.renderStops()}
493
+ ${this.canAddStop
494
+ ? html`<button
495
+ class="floor-plan-badge add-stop"
496
+ @click=${() => emit(this, "add-stop", {})}
497
+ >
498
+ + Add another stop
499
+ </button>`
500
+ : ""}`;
501
+ }
477
502
  const itinerary = !this.selectedTypeOpensLink && !this.single;
478
503
  return html`<div id="tour-type-menu-outer-container">
479
504
  ${this.renderCommunity()} ${this.renderTourTypes()}
@@ -524,6 +549,15 @@ export class ItineraryEditor extends LitElement {
524
549
  margin-top: 20px;
525
550
  }
526
551
 
552
+ /* The pencil sits centred on the community card's right. */
553
+ .icon-button.change-community {
554
+ align-self: center;
555
+ }
556
+
557
+ .add-stop {
558
+ width: 100%;
559
+ }
560
+
527
561
  .community {
528
562
  background: #ffffff;
529
563
  border: 1px solid #e7e7e7;