@meetelise/chat 1.20.1 → 1.20.3

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.
@@ -38,6 +38,10 @@ export class Launcher extends LitElement {
38
38
  chatCallUsHeader = "Call us";
39
39
  @property({ attribute: false })
40
40
  buildingId = 0;
41
+ @property({ attribute: true })
42
+ buildingSlug = "";
43
+ @property({ attribute: true })
44
+ orgSlug = "";
41
45
  @property({ type: Boolean })
42
46
  hasCallUsEnabled = false;
43
47
  @property({ type: Boolean })
@@ -266,6 +270,8 @@ export class Launcher extends LitElement {
266
270
  ${this.isEmailWindowOpen
267
271
  ? html`<div class="launcher__window-wrapper">
268
272
  <email-us-window
273
+ orgSlug="${this.orgSlug}"
274
+ buildingSlug="${this.buildingSlug}"
269
275
  ${ref(this.emailUsWindowRef)}
270
276
  .buildingId=${this.buildingId}
271
277
  >
@@ -275,6 +281,8 @@ export class Launcher extends LitElement {
275
281
  ${this.isTextUsWindowOpen
276
282
  ? html`<div class="launcher__window-wrapper">
277
283
  <text-us-window
284
+ orgSlug="${this.orgSlug}"
285
+ buildingSlug="${this.buildingSlug}"
278
286
  ${ref(this.textUsWindowRef)}
279
287
  .buildingId=${this.buildingId}
280
288
  ></text-us-window>
@@ -283,6 +291,8 @@ export class Launcher extends LitElement {
283
291
  ${this.isSSTWindowOpen
284
292
  ? html`<div class="launcher__window-wrapper">
285
293
  <tour-scheduler
294
+ orgSlug="${this.orgSlug}"
295
+ buildingSlug="${this.buildingSlug}"
286
296
  .layoutOptions=${this.layoutOptions}
287
297
  .tourTypeOptions=${this.tourTypeOptions}
288
298
  buildingId=${this.buildingId}
@@ -1,11 +1,27 @@
1
1
  import { LitElement, html, TemplateResult, css } from "lit";
2
2
  import { customElement, property, state } from "lit/decorators.js";
3
3
  import { classMap } from "lit/directives/class-map.js";
4
+ import { DateWithTimeZoneOffset } from "../../getAvailabilities";
5
+
6
+ export type TimePickerOption = {
7
+ displayTime: string;
8
+ dateWithTimeZoneOffset: DateWithTimeZoneOffset;
9
+ };
10
+
11
+ const getDateWithTimezoneOffset = (
12
+ options: TimePickerOption[],
13
+ displayTime: string
14
+ ) => {
15
+ return options.reduce(function (map: Record<string, TimePickerOption>, obj) {
16
+ map[obj.displayTime] = obj;
17
+ return map;
18
+ }, {})[displayTime];
19
+ };
4
20
 
5
21
  @customElement("time-picker")
6
22
  export class TimePicker extends LitElement {
7
23
  @property({ attribute: false })
8
- options: string[] = [];
24
+ options: TimePickerOption[] = [];
9
25
 
10
26
  @property({ type: Boolean })
11
27
  selectedDateExists = false;
@@ -14,10 +30,10 @@ export class TimePicker extends LitElement {
14
30
  horizontal = false;
15
31
 
16
32
  @state()
17
- private selected?: string;
33
+ private selected?: TimePickerOption;
18
34
 
19
35
  @property({ attribute: false })
20
- get selectedTime(): undefined | string {
36
+ get selectedTime(): undefined | TimePickerOption {
21
37
  return this.selected;
22
38
  }
23
39
 
@@ -100,8 +116,12 @@ export class TimePicker extends LitElement {
100
116
  class=${this.horizontal ? "horizontal" : ""}
101
117
  @click="${(e: MouseEvent) => {
102
118
  const target = e.target as HTMLElement | undefined;
119
+
103
120
  if (target?.closest(".option:not(.selected)"))
104
- this.selected = target.innerText;
121
+ this.selected = getDateWithTimezoneOffset(
122
+ this.options,
123
+ target.innerText
124
+ );
105
125
  this.dispatchEvent(
106
126
  new Event("change", { bubbles: true, composed: true })
107
127
  );
@@ -114,8 +134,8 @@ export class TimePicker extends LitElement {
114
134
  ) {
115
135
  e.preventDefault();
116
136
  this.selected =
117
- target.innerText !== this.selected
118
- ? target.innerText
137
+ target.innerText !== this.selected?.displayTime
138
+ ? getDateWithTimezoneOffset(this.options, target.innerText)
119
139
  : undefined;
120
140
  this.dispatchEvent(
121
141
  new Event("change", { bubbles: true, composed: true })
@@ -127,11 +147,11 @@ export class TimePicker extends LitElement {
127
147
  (option) =>
128
148
  html`<div
129
149
  class="option ${classMap({
130
- selected: this.selected === option,
150
+ selected: this.selected?.displayTime === option.displayTime,
131
151
  })}"
132
152
  tabindex="0"
133
153
  >
134
- <span>${option}</span>
154
+ <span>${option.displayTime}</span>
135
155
  </div>`
136
156
  )}
137
157
  </div>
@@ -34,7 +34,10 @@ export class TourScheduler extends LitElement {
34
34
  tourTypeOptions: LabeledOption[] = [];
35
35
  @property({ type: Number })
36
36
  buildingId = 0;
37
- @property({ attribute: false })
37
+ @property({ attribute: true })
38
+ buildingSlug = "";
39
+ @property({ attribute: true })
40
+ orgSlug = "";
38
41
  onCloseClicked?: (e: MouseEvent) => void;
39
42
 
40
43
  @state()
@@ -313,7 +316,11 @@ export class TourScheduler extends LitElement {
313
316
  const url = `https://app.meetelise.com/platformApi/state/create/scheduleMe`;
314
317
  this.isSubmitting = true;
315
318
  const response = await axios.post(url, data, {
316
- headers: { ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG" },
319
+ headers: {
320
+ ["building-slug"]: this.buildingSlug,
321
+ ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG",
322
+ ["org-slug"]: this.orgSlug,
323
+ },
317
324
  });
318
325
  if (response.status === 200) {
319
326
  this.isSubmitting = false;
@@ -825,9 +832,15 @@ export class TourScheduler extends LitElement {
825
832
  .options=${this.selectedDate
826
833
  ? this.availabilitiesGroupedByDay[
827
834
  format(this.selectedDate, "y-MM-dd")
828
- ]?.map((date) =>
829
- format(parseISO(`${date.datetime}${date.offset}`), "h:mmaaa")
830
- )
835
+ ]?.map((date) => {
836
+ return {
837
+ dateWithTimeZoneOffset: date,
838
+ displayTime: format(
839
+ parseISO(`${date.datetime}${date.offset}`),
840
+ "h:mmaaa"
841
+ ),
842
+ };
843
+ })
831
844
  : []}
832
845
  @change=${(e: Event) => {
833
846
  if (e.target instanceof TimePicker) {
@@ -837,9 +850,9 @@ export class TourScheduler extends LitElement {
837
850
  format(new Date(this.selectedDate), "y-MM-dd")
838
851
  ];
839
852
  const index = e.target.selectedTime
840
- ? daysAvailabilities
841
- .map((date) => format(new Date(date.datetime), "h:mmaaa"))
842
- .indexOf(e.target.selectedTime)
853
+ ? daysAvailabilities.indexOf(
854
+ e.target.selectedTime.dateWithTimeZoneOffset
855
+ )
843
856
  : null;
844
857
  this.selectedTime =
845
858
  index !== null ? daysAvailabilities[index] : null;
@@ -981,10 +994,10 @@ export class TourScheduler extends LitElement {
981
994
  confirmationMessage(): TemplateResult {
982
995
  if (!this.selectedDate || !this.selectedTime) return html``;
983
996
  // format example: "November 9th, 2022 at 11:00am"
984
- const readableDateAndTime = `${format(
985
- new Date(this.selectedDate),
986
- "MMMM do, y"
987
- )} at ${format(new Date(this.selectedTime.datetime), "h:mmaaa")}`;
997
+ const readableDateAndTime = format(
998
+ parseISO(`${this.selectedTime.datetime}${this.selectedTime.offset}`),
999
+ "h:mmaaa"
1000
+ );
988
1001
  return html`
989
1002
  <div id="confirmationMessage">
990
1003
  <svg
@@ -88,6 +88,10 @@ export class EmailUsWindow extends LitElement {
88
88
 
89
89
  @property({ attribute: false })
90
90
  buildingId = 0;
91
+ @property({ attribute: true })
92
+ buildingSlug = "";
93
+ @property({ attribute: true })
94
+ orgSlug = "";
91
95
 
92
96
  phoneNumberInputRef: Ref<HTMLInputElement> = createRef();
93
97
 
@@ -220,7 +224,9 @@ export class EmailUsWindow extends LitElement {
220
224
  this.email,
221
225
  this.phoneNumber,
222
226
  this.message,
223
- this.buildingId
227
+ this.buildingId,
228
+ this.orgSlug,
229
+ this.buildingSlug
224
230
  );
225
231
  this.hasSubmittedForm = true;
226
232
  this.isSubmitting = false;
@@ -403,7 +409,9 @@ const createEmail = async (
403
409
  email: string,
404
410
  rawPhoneNumber: string,
405
411
  message: string,
406
- buildingId: number
412
+ buildingId: number,
413
+ orgSlug: string,
414
+ buildingSlug: string
407
415
  ) => {
408
416
  const formattedPhoneNumber =
409
417
  "+1" +
@@ -425,6 +433,12 @@ const createEmail = async (
425
433
  await axios.post(
426
434
  "https://app.meetelise.com/platformApi/state/create/emailMe",
427
435
  requestBody,
428
- { headers: { ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG" } }
436
+ {
437
+ headers: {
438
+ ["building-slug"]: buildingSlug,
439
+ ["org-slug"]: orgSlug,
440
+ ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG",
441
+ },
442
+ }
429
443
  );
430
444
  };
@@ -55,6 +55,10 @@ export class TextUsWindow extends LitElement {
55
55
 
56
56
  @property({ attribute: false })
57
57
  buildingId = 0;
58
+ @property({ attribute: true })
59
+ buildingSlug = "";
60
+ @property({ attribute: true })
61
+ orgSlug = "";
58
62
 
59
63
  phoneNumberInputRef: Ref<HTMLInputElement> = createRef();
60
64
 
@@ -104,7 +108,12 @@ export class TextUsWindow extends LitElement {
104
108
  }
105
109
  try {
106
110
  this.isSubmitting = true;
107
- await createTextWithUs(this.phoneNumber, this.buildingId);
111
+ await createTextWithUs(
112
+ this.phoneNumber,
113
+ this.buildingId,
114
+ this.orgSlug,
115
+ this.buildingSlug
116
+ );
108
117
  this.hasSubmittedForm = true;
109
118
  this.isSubmitting = false;
110
119
  } catch (e) {
@@ -203,7 +212,12 @@ export const installTextUsWindow = (): void => {
203
212
  }
204
213
  };
205
214
 
206
- const createTextWithUs = async (rawPhoneNumber: string, buildingId: number) => {
215
+ const createTextWithUs = async (
216
+ rawPhoneNumber: string,
217
+ buildingId: number,
218
+ orgSlug: string,
219
+ buildingSlug: string
220
+ ) => {
207
221
  const formattedPhoneNumber =
208
222
  "+1" +
209
223
  rawPhoneNumber
@@ -220,6 +234,12 @@ const createTextWithUs = async (rawPhoneNumber: string, buildingId: number) => {
220
234
  await axios.post(
221
235
  "https://app.meetelise.com/platformApi/state/create/textMe",
222
236
  requestBody,
223
- { headers: { ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG" } }
237
+ {
238
+ headers: {
239
+ ["building-slug"]: buildingSlug,
240
+ ["org-slug"]: orgSlug,
241
+ ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG",
242
+ },
243
+ }
224
244
  );
225
245
  };
@@ -292,6 +292,8 @@ export class MEChat extends LitElement {
292
292
  phoneNumber="${this.building?.phoneNumber ?? ""}"
293
293
  textColor="${this.theme.chatHeader.textColor}"
294
294
  backgroundColor="${this.theme.chatPaneBackgroundColor}"
295
+ orgSlug="${this.orgSlug}"
296
+ buildingSlug="${this.buildingSlug}"
295
297
  ?hidden=${this.hideLauncher}
296
298
  ?hasCallUsEnabled=${!this.building?.chatWidgets
297
299
  ? true