@meetelise/chat 1.13.11 → 1.14.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.
@@ -12,6 +12,7 @@ import "./me-select.ts";
12
12
  import {
13
13
  DateWithTimeZoneOffset,
14
14
  getAvailabilitiesGroupedByDay,
15
+ getExistenceOfAvailabilitiesByTourType,
15
16
  } from "../../getAvailabilities";
16
17
  import { TourAvailabilityResponseRankOrderedSupportedTourTypesEnum } from "@meetelise/rest-sdk";
17
18
  import { format } from "date-fns";
@@ -37,6 +38,12 @@ export class TourScheduler extends LitElement {
37
38
  @state()
38
39
  private tourType = TourType.Guided;
39
40
  @state()
41
+ private shouldShowTourType = {
42
+ [TourType.Guided]: true,
43
+ [TourType.Self]: true,
44
+ [TourType.Virtual]: true,
45
+ };
46
+ @state()
40
47
  private email = "";
41
48
  @state()
42
49
  private phoneNumber = "";
@@ -68,6 +75,22 @@ export class TourScheduler extends LitElement {
68
75
  this.availabilitiesGroupedByDay = await getAvailabilitiesGroupedByDay(
69
76
  tourTypeMap[this.tourType]
70
77
  );
78
+
79
+ // Show a tour type only if it is supported by the building and has
80
+ // time slots available.
81
+ const availabilitiesExistForTourType =
82
+ await getExistenceOfAvailabilitiesByTourType();
83
+ this.shouldShowTourType = {
84
+ [TourType.Guided]:
85
+ this.tourTypeOptions.map((o) => o.value).includes("WITH_AGENT") &&
86
+ availabilitiesExistForTourType[TourType.Guided],
87
+ [TourType.Self]:
88
+ this.tourTypeOptions.map((o) => o.value).includes("SELF_GUIDED") &&
89
+ availabilitiesExistForTourType[TourType.Self],
90
+ [TourType.Virtual]:
91
+ this.tourTypeOptions.map((o) => o.value).includes("VIRTUAL_SHOWING") &&
92
+ availabilitiesExistForTourType[TourType.Virtual],
93
+ };
71
94
  };
72
95
 
73
96
  protected willUpdate = async (
@@ -476,6 +499,15 @@ export class TourScheduler extends LitElement {
476
499
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);
477
500
  }
478
501
 
502
+ button#schedule:not(:disabled):hover {
503
+ opacity: 0.7;
504
+ }
505
+
506
+ button#schedule:not(:disabled):active {
507
+ box-shadow: none;
508
+ opacity: 1;
509
+ }
510
+
479
511
  button#schedule:disabled {
480
512
  background: #e7e7e7;
481
513
  box-shadow: none;
@@ -606,7 +638,7 @@ export class TourScheduler extends LitElement {
606
638
  tourTypeMenu(): TemplateResult {
607
639
  return html`<h2 id="tourType">Tour Type</h2>
608
640
  <div id="tourTypeMenu">
609
- ${this.tourTypeOptions.map((o) => o.value).includes("WITH_AGENT")
641
+ ${this.shouldShowTourType[TourType.Guided]
610
642
  ? html` <tour-type-option
611
643
  heading="Guided tour"
612
644
  subtitle="with an agent"
@@ -638,7 +670,7 @@ export class TourScheduler extends LitElement {
638
670
  </svg>
639
671
  </tour-type-option>`
640
672
  : ""}
641
- ${this.tourTypeOptions.map((o) => o.value).includes("SELF_GUIDED")
673
+ ${this.shouldShowTourType[TourType.Self]
642
674
  ? html`<tour-type-option
643
675
  heading="Take a tour"
644
676
  subtitle="on your own"
@@ -670,7 +702,7 @@ export class TourScheduler extends LitElement {
670
702
  </svg>
671
703
  </tour-type-option>`
672
704
  : ""}
673
- ${this.tourTypeOptions.map((o) => o.value).includes("VIRTUAL_SHOWING")
705
+ ${this.shouldShowTourType[TourType.Virtual]
674
706
  ? html`<tour-type-option
675
707
  heading="Virtual tour"
676
708
  subtitle="over video"
@@ -879,7 +911,13 @@ export class TourScheduler extends LitElement {
879
911
  <p>
880
912
  Thank you!
881
913
  <br />
882
- Your guided tour is scheduled for ${readableDateAndTime}.
914
+ Your
915
+ ${{
916
+ [TourType.Guided]: "guided",
917
+ [TourType.Self]: "self-guided",
918
+ [TourType.Virtual]: "virtual",
919
+ }[this.tourType]}
920
+ tour is scheduled for ${readableDateAndTime}.
883
921
  </p>
884
922
  <p>
885
923
  Look for an email confirmation along with instructions and directions.
@@ -947,8 +985,6 @@ export enum TourType {
947
985
  Virtual,
948
986
  }
949
987
 
950
- // TODO: we have three UI options and five TourAvailabilityResponseRankOrderedSupportedTourTypesEnum values
951
- // how should they map?
952
988
  const tourTypeMap = {
953
989
  [TourType.Guided]:
954
990
  TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent,
@@ -10,6 +10,7 @@ import {
10
10
  TourAvailabilityResponseRankOrderedSupportedTourTypesEnum,
11
11
  } from "@meetelise/rest-sdk";
12
12
  import groupBy from "lodash/groupBy";
13
+ import { TourType } from "./WebComponent/Scheduler/tour-scheduler";
13
14
 
14
15
  const availabilitiesCache: {
15
16
  buildingId?: number | null;
@@ -85,6 +86,39 @@ export interface DateWithTimeZoneOffset {
85
86
  offset: string;
86
87
  }
87
88
 
89
+ /**
90
+ * Returns an object that reveals whether each tour type supported by
91
+ * `tour-scheduler` has availabilities (time slots available for scheduling) in
92
+ * the time window of interest.
93
+ *
94
+ * Note that the existence of current availabilities is distinct from the
95
+ * question of whether the community supports the tour type at all. The first
96
+ * implies the second but not vice versa.
97
+ */
98
+ export const getExistenceOfAvailabilitiesByTourType = async (): Promise<{
99
+ [TourType.Guided]: boolean;
100
+ [TourType.Self]: boolean;
101
+ [TourType.Virtual]: boolean;
102
+ }> => {
103
+ return {
104
+ [TourType.Guided]: !!(
105
+ await getAvailabilitiesForTourType(
106
+ TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent
107
+ )
108
+ )?.availableTourStartTimes?.length,
109
+ [TourType.Self]: !!(
110
+ await getAvailabilitiesForTourType(
111
+ TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided
112
+ )
113
+ )?.availableTourStartTimes?.length,
114
+ [TourType.Virtual]: !!(
115
+ await getAvailabilitiesForTourType(
116
+ TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing
117
+ )
118
+ )?.availableTourStartTimes?.length,
119
+ };
120
+ };
121
+
88
122
  export const getAvailabilitiesGroupedByDay = async (
89
123
  tourType: TourAvailabilityResponseRankOrderedSupportedTourTypesEnum,
90
124
  buildingId?: number