@meetelise/chat 1.61.1 → 1.62.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.
@@ -316,10 +316,19 @@ export class TourScheduler extends LitElement {
316
316
  @state()
317
317
  private useCoastalCustomTourTypes = false;
318
318
 
319
+ @state()
320
+ private tourTypeOrder: TourType[] = defaultTourTypeOrder;
321
+
322
+ private coastalTourLabel(tourType: TourType): string | undefined {
323
+ return this.useCoastalCustomTourTypes
324
+ ? coastalTourLabels[tourType]
325
+ : undefined;
326
+ }
327
+
319
328
  private confirmationTourName(tourType: TourType): string {
320
- return tourType === TourType.Self && this.useCoastalCustomTourTypes
321
- ? coastalSelfGuidedTourLabel
322
- : defaultConfirmationTourNames[tourType];
329
+ return (
330
+ this.coastalTourLabel(tourType) ?? defaultConfirmationTourNames[tourType]
331
+ );
323
332
  }
324
333
 
325
334
  _setAvailabilities = async (): Promise<void> => {
@@ -574,11 +583,12 @@ export class TourScheduler extends LitElement {
574
583
  const useCoastalCustomTourTypes = fetchTrackedRolloutCoastalCustomTourTypes(
575
584
  this.buildingSlug
576
585
  );
577
- try {
578
- await getRawAvailabilities(this.buildingId);
579
- } catch (e) {
580
- // noop
581
- }
586
+ this.tourTypeOrder = tourTypeOrderFor(
587
+ await getRawAvailabilities(this.buildingId).then(
588
+ (availabilities) => availabilities.rankOrderedSupportedTourTypes ?? [],
589
+ () => []
590
+ )
591
+ );
582
592
  this.useCoastalCustomTourTypes = await useCoastalCustomTourTypes;
583
593
  await Promise.all([
584
594
  this._setAvailabilities().then(async () => {
@@ -1026,6 +1036,144 @@ export class TourScheduler extends LitElement {
1026
1036
  static styles = [tourSchedulerStyles, InputStyles];
1027
1037
 
1028
1038
  tourTypeMenu(): TemplateResult {
1039
+ const options: Record<TourType, TemplateResult | string> = {
1040
+ [TourType.Self]: this.shouldShowTourType[TourType.Self]
1041
+ ? html` <tour-type-option
1042
+ heading=${this.coastalTourLabel(TourType.Self) ?? "Take a tour"}
1043
+ subtitle=${this.coastalTourLabel(TourType.Self)
1044
+ ? ""
1045
+ : "on your own"}
1046
+ .primaryColor=${this.primaryColor}
1047
+ .foregroundColorOnPrimaryBackgroundColor=${this
1048
+ .foregroundColorOnPrimaryBackgroundColor}
1049
+ @click="${async () => {
1050
+ this.tourType = TourType.Self;
1051
+ pushGtmEvent("tourTypeSelected", {
1052
+ tourType: TourType.Self,
1053
+ buildingId: this.buildingId,
1054
+ });
1055
+ if (
1056
+ this.sgtUrl &&
1057
+ shouldOpenTourLink(
1058
+ TourType.Self,
1059
+ this.selfGuidedToursTypeOffered
1060
+ )
1061
+ ) {
1062
+ this.openSelfGuidedTour();
1063
+ }
1064
+ this.availabilitiesGroupedByDay =
1065
+ await getAvailabilitiesGroupedByDay(tourTypeMap[TourType.Self]);
1066
+ this._setDefaultSelectedDateAndTimes(tourTypeMap[TourType.Self]);
1067
+ }}"
1068
+ @keydown="${(e: KeyboardEvent) => {
1069
+ if ([" ", "Enter"].includes(e.key)) {
1070
+ e.preventDefault();
1071
+ this.tourType = TourType.Self;
1072
+ }
1073
+ }}"
1074
+ ?selected="${this.tourType === TourType.Self}"
1075
+ >
1076
+ ${TourSelfGuidedIcon(
1077
+ this.tourType === TourType.Self
1078
+ ? this.foregroundColorOnPrimaryBackgroundColor
1079
+ : unselectedTourTypeForegroundColor
1080
+ )}
1081
+ </tour-type-option>`
1082
+ : "",
1083
+ [TourType.Guided]: this.shouldShowTourType[TourType.Guided]
1084
+ ? html` <tour-type-option
1085
+ heading=${this.coastalTourLabel(TourType.Guided) ?? "Guided tour"}
1086
+ subtitle=${this.coastalTourLabel(TourType.Guided)
1087
+ ? ""
1088
+ : "with an agent"}
1089
+ .primaryColor=${this.primaryColor}
1090
+ .foregroundColorOnPrimaryBackgroundColor=${this
1091
+ .foregroundColorOnPrimaryBackgroundColor}
1092
+ @click="${async () => {
1093
+ this.tourType = TourType.Guided;
1094
+ pushGtmEvent("tourTypeSelected", {
1095
+ tourType: TourType.Guided,
1096
+ buildingId: this.buildingId,
1097
+ });
1098
+
1099
+ if (
1100
+ this.escortedToursLink &&
1101
+ shouldOpenTourLink(
1102
+ TourType.Guided,
1103
+ this.escortedToursTypeOffered
1104
+ )
1105
+ ) {
1106
+ window.open(this.escortedToursLink, "_blank");
1107
+ }
1108
+ this.availabilitiesGroupedByDay =
1109
+ await getAvailabilitiesGroupedByDay(
1110
+ tourTypeMap[TourType.Guided]
1111
+ );
1112
+ this._setDefaultSelectedDateAndTimes(
1113
+ tourTypeMap[TourType.Guided]
1114
+ );
1115
+ }}"
1116
+ @keydown="${(e: KeyboardEvent) => {
1117
+ if ([" ", "Enter"].includes(e.key)) {
1118
+ e.preventDefault();
1119
+ this.tourType = TourType.Guided;
1120
+ }
1121
+ }}"
1122
+ ?selected="${this.tourType === TourType.Guided}"
1123
+ >
1124
+ ${TourWithAgentIcon(
1125
+ this.tourType === TourType.Guided
1126
+ ? this.foregroundColorOnPrimaryBackgroundColor
1127
+ : unselectedTourTypeForegroundColor
1128
+ )}
1129
+ </tour-type-option>`
1130
+ : "",
1131
+ [TourType.Virtual]: this.shouldShowTourType[TourType.Virtual]
1132
+ ? html` <tour-type-option
1133
+ heading="Virtual tour"
1134
+ subtitle="over video"
1135
+ .primaryColor=${this.primaryColor}
1136
+ .foregroundColorOnPrimaryBackgroundColor=${this
1137
+ .foregroundColorOnPrimaryBackgroundColor}
1138
+ @click="${async () => {
1139
+ this.tourType = TourType.Virtual;
1140
+ pushGtmEvent("tourTypeSelected", {
1141
+ tourType: TourType.Virtual,
1142
+ buildingId: this.buildingId,
1143
+ });
1144
+ if (
1145
+ this.virtualToursLink &&
1146
+ shouldOpenTourLink(
1147
+ TourType.Virtual,
1148
+ this.virtualToursTypeOffered
1149
+ )
1150
+ ) {
1151
+ window.open(this.virtualToursLink, "_blank");
1152
+ }
1153
+ this.availabilitiesGroupedByDay =
1154
+ await getAvailabilitiesGroupedByDay(
1155
+ tourTypeMap[TourType.Virtual]
1156
+ );
1157
+ this._setDefaultSelectedDateAndTimes(
1158
+ tourTypeMap[TourType.Virtual]
1159
+ );
1160
+ }}"
1161
+ @keydown="${(e: KeyboardEvent) => {
1162
+ if ([" ", "Enter"].includes(e.key)) {
1163
+ e.preventDefault();
1164
+ this.tourType = TourType.Virtual;
1165
+ }
1166
+ }}"
1167
+ ?selected="${this.tourType === TourType.Virtual}"
1168
+ >
1169
+ ${TourVirtuallyIcon(
1170
+ this.tourType === TourType.Virtual
1171
+ ? this.foregroundColorOnPrimaryBackgroundColor
1172
+ : unselectedTourTypeForegroundColor
1173
+ )}
1174
+ </tour-type-option>`
1175
+ : "",
1176
+ };
1029
1177
  return html`${this.buildingSelector()}
1030
1178
  <h2 id="tour-type-heading" class="journey-header">Tour Type</h2>
1031
1179
  <div
@@ -1033,144 +1181,7 @@ export class TourScheduler extends LitElement {
1033
1181
  role="radiogroup"
1034
1182
  aria-labelledby="tour-type-heading"
1035
1183
  >
1036
- ${this.shouldShowTourType[TourType.Self]
1037
- ? html` <tour-type-option
1038
- heading=${this.useCoastalCustomTourTypes
1039
- ? coastalSelfGuidedTourLabel
1040
- : "Take a tour"}
1041
- subtitle=${this.useCoastalCustomTourTypes ? "" : "on your own"}
1042
- .primaryColor=${this.primaryColor}
1043
- .foregroundColorOnPrimaryBackgroundColor=${this
1044
- .foregroundColorOnPrimaryBackgroundColor}
1045
- @click="${async () => {
1046
- this.tourType = TourType.Self;
1047
- pushGtmEvent("tourTypeSelected", {
1048
- tourType: TourType.Self,
1049
- buildingId: this.buildingId,
1050
- });
1051
- if (
1052
- this.sgtUrl &&
1053
- shouldOpenTourLink(
1054
- TourType.Self,
1055
- this.selfGuidedToursTypeOffered
1056
- )
1057
- ) {
1058
- this.openSelfGuidedTour();
1059
- }
1060
- this.availabilitiesGroupedByDay =
1061
- await getAvailabilitiesGroupedByDay(
1062
- tourTypeMap[TourType.Self]
1063
- );
1064
- this._setDefaultSelectedDateAndTimes(
1065
- tourTypeMap[TourType.Self]
1066
- );
1067
- }}"
1068
- @keydown="${(e: KeyboardEvent) => {
1069
- if ([" ", "Enter"].includes(e.key)) {
1070
- e.preventDefault();
1071
- this.tourType = TourType.Self;
1072
- }
1073
- }}"
1074
- ?selected="${this.tourType === TourType.Self}"
1075
- >
1076
- ${TourSelfGuidedIcon(
1077
- this.tourType === TourType.Self
1078
- ? this.foregroundColorOnPrimaryBackgroundColor
1079
- : unselectedTourTypeForegroundColor
1080
- )}
1081
- </tour-type-option>`
1082
- : ""}
1083
- ${this.shouldShowTourType[TourType.Guided]
1084
- ? html` <tour-type-option
1085
- heading="Guided tour"
1086
- subtitle="with an agent"
1087
- .primaryColor=${this.primaryColor}
1088
- .foregroundColorOnPrimaryBackgroundColor=${this
1089
- .foregroundColorOnPrimaryBackgroundColor}
1090
- @click="${async () => {
1091
- this.tourType = TourType.Guided;
1092
- pushGtmEvent("tourTypeSelected", {
1093
- tourType: TourType.Guided,
1094
- buildingId: this.buildingId,
1095
- });
1096
-
1097
- if (
1098
- this.escortedToursLink &&
1099
- shouldOpenTourLink(
1100
- TourType.Guided,
1101
- this.escortedToursTypeOffered
1102
- )
1103
- ) {
1104
- window.open(this.escortedToursLink, "_blank");
1105
- }
1106
- this.availabilitiesGroupedByDay =
1107
- await getAvailabilitiesGroupedByDay(
1108
- tourTypeMap[TourType.Guided]
1109
- );
1110
- this._setDefaultSelectedDateAndTimes(
1111
- tourTypeMap[TourType.Guided]
1112
- );
1113
- }}"
1114
- @keydown="${(e: KeyboardEvent) => {
1115
- if ([" ", "Enter"].includes(e.key)) {
1116
- e.preventDefault();
1117
- this.tourType = TourType.Guided;
1118
- }
1119
- }}"
1120
- ?selected="${this.tourType === TourType.Guided}"
1121
- >
1122
- ${TourWithAgentIcon(
1123
- this.tourType === TourType.Guided
1124
- ? this.foregroundColorOnPrimaryBackgroundColor
1125
- : unselectedTourTypeForegroundColor
1126
- )}
1127
- </tour-type-option>`
1128
- : ""}
1129
- ${this.shouldShowTourType[TourType.Virtual]
1130
- ? html` <tour-type-option
1131
- heading="Virtual tour"
1132
- subtitle="over video"
1133
- .primaryColor=${this.primaryColor}
1134
- .foregroundColorOnPrimaryBackgroundColor=${this
1135
- .foregroundColorOnPrimaryBackgroundColor}
1136
- @click="${async () => {
1137
- this.tourType = TourType.Virtual;
1138
- pushGtmEvent("tourTypeSelected", {
1139
- tourType: TourType.Virtual,
1140
- buildingId: this.buildingId,
1141
- });
1142
- if (
1143
- this.virtualToursLink &&
1144
- shouldOpenTourLink(
1145
- TourType.Virtual,
1146
- this.virtualToursTypeOffered
1147
- )
1148
- ) {
1149
- window.open(this.virtualToursLink, "_blank");
1150
- }
1151
- this.availabilitiesGroupedByDay =
1152
- await getAvailabilitiesGroupedByDay(
1153
- tourTypeMap[TourType.Virtual]
1154
- );
1155
- this._setDefaultSelectedDateAndTimes(
1156
- tourTypeMap[TourType.Virtual]
1157
- );
1158
- }}"
1159
- @keydown="${(e: KeyboardEvent) => {
1160
- if ([" ", "Enter"].includes(e.key)) {
1161
- e.preventDefault();
1162
- this.tourType = TourType.Virtual;
1163
- }
1164
- }}"
1165
- ?selected="${this.tourType === TourType.Virtual}"
1166
- >
1167
- ${TourVirtuallyIcon(
1168
- this.tourType === TourType.Virtual
1169
- ? this.foregroundColorOnPrimaryBackgroundColor
1170
- : unselectedTourTypeForegroundColor
1171
- )}
1172
- </tour-type-option>`
1173
- : ""}
1184
+ ${this.tourTypeOrder.map((tourType) => options[tourType])}
1174
1185
  </div>`;
1175
1186
  }
1176
1187
 
@@ -2182,7 +2193,26 @@ const rankedOrderTourTypeToTourType = {
2182
2193
  TourType.Virtual,
2183
2194
  };
2184
2195
 
2185
- const coastalSelfGuidedTourLabel = "VIP Hard Hat Tour";
2196
+ const coastalTourLabels: Partial<Record<TourType, string>> = {
2197
+ [TourType.Guided]: "In-Person Tour",
2198
+ [TourType.Self]: "VIP Hard Hat Tour",
2199
+ };
2200
+
2201
+ const defaultTourTypeOrder = [TourType.Guided, TourType.Self, TourType.Virtual];
2202
+
2203
+ function tourTypeOrderFor(
2204
+ rankOrderedSupportedTourTypes: TourAvailabilityResponseRankOrderedSupportedTourTypesEnum[]
2205
+ ): TourType[] {
2206
+ const ranked = rankOrderedSupportedTourTypes.flatMap((rankedType) =>
2207
+ defaultTourTypeOrder.filter(
2208
+ (tourType) => tourTypeMap[tourType] === rankedType
2209
+ )
2210
+ );
2211
+ let next = 0;
2212
+ return defaultTourTypeOrder.map((tourType) =>
2213
+ ranked.includes(tourType) ? ranked[next++] : tourType
2214
+ );
2215
+ }
2186
2216
 
2187
2217
  const defaultConfirmationTourNames: Record<TourType, string> = {
2188
2218
  [TourType.Guided]: "guided tour",