@meetelise/chat 1.12.8 → 1.12.11

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.
package/src/MEChat.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ThemeIdString } from "./themes";
2
2
  import "./WebComponent/me-chat";
3
+ import { MEChat as MEChatLitElement } from "./WebComponent/me-chat";
3
4
 
4
5
  /**
5
6
  * The interface to MeetElise chat.
@@ -14,6 +15,8 @@ import "./WebComponent/me-chat";
14
15
  * });
15
16
  */
16
17
  export default class MEChat {
18
+ static meChat: MEChatLitElement | null = null;
19
+
17
20
  static start(opts: Options): void {
18
21
  installFont();
19
22
  const meChat = document.createElement("me-chat");
@@ -29,6 +32,14 @@ export default class MEChat {
29
32
  meChat.useMiniWidget = opts.mini;
30
33
  }
31
34
  document.body.appendChild(meChat);
35
+ MEChat.meChat = meChat;
36
+ }
37
+
38
+ static async restartConversation(): Promise<void> {
39
+ if (!this.meChat) {
40
+ return;
41
+ }
42
+ await this.meChat.restartConversation();
32
43
  }
33
44
  }
34
45
 
@@ -1,3 +1,5 @@
1
+ // TODO: remove this when sst fixed
2
+ /* eslint-disable lit/binding-positions */
1
3
  import classnames from "classnames";
2
4
  import { html, LitElement, TemplateResult } from "lit";
3
5
  import { customElement, property, state } from "lit/decorators.js";
@@ -39,7 +41,9 @@ export class Launcher extends LitElement {
39
41
  @property({ type: Boolean })
40
42
  hasEmailEnabled = true;
41
43
  @property({ type: Boolean })
42
- hasSSTEnabled = true;
44
+ // TODO: re-enable
45
+ // hasSSTEnabled = true;
46
+ hasSSTEnabled = false;
43
47
  @property({ type: Boolean })
44
48
  hasTextUsEnabled = false;
45
49
  @property({ attribute: false })
@@ -64,7 +68,8 @@ export class Launcher extends LitElement {
64
68
  return [
65
69
  this.hasEmailEnabled,
66
70
  !!this.phoneNumber,
67
- this.hasSSTEnabled,
71
+ // TODO: re-enable
72
+ // this.hasSSTEnabled,
68
73
  this.hasTextUsEnabled,
69
74
  ].filter((v) => v).length;
70
75
  };
@@ -200,7 +205,8 @@ export class Launcher extends LitElement {
200
205
  ${this.hasEmailEnabled ? this.renderEmailOption() : ""}
201
206
  ${this.phoneNumber ? this.renderCallUsOption() : ""}
202
207
  ${this.hasTextUsEnabled ? this.renderTextUsOption() : ""}
203
- ${this.hasSSTEnabled ? this.renderSSTOption() : ""}
208
+ <!-- TODO: re-enable -->
209
+ <!-- ${this.hasSSTEnabled ? this.renderSSTOption() : ""} -->
204
210
  </div>
205
211
  `;
206
212
  };
@@ -315,7 +321,8 @@ export class Launcher extends LitElement {
315
321
  true
316
322
  )
317
323
  : ""}
318
- ${this.hasSSTEnabled && !this.isCallToActionWindowOpen()
324
+ <!-- TODO: re-enable -->
325
+ <!-- ${this.hasSSTEnabled && !this.isCallToActionWindowOpen()
319
326
  ? this.renderMiniOption(
320
327
  html`
321
328
  <svg
@@ -334,7 +341,7 @@ export class Launcher extends LitElement {
334
341
  this.onClickSSTOption,
335
342
  true
336
343
  )
337
- : ""}
344
+ : ""} -->
338
345
  ${this.phoneNumber && !this.isCallToActionWindowOpen()
339
346
  ? this.renderMiniOption(
340
347
  html`
@@ -273,7 +273,9 @@ export class TourScheduler extends LitElement {
273
273
  tour_time: tourTimeString,
274
274
  };
275
275
  const url = `https://app.meetelise.com/platformApi/state/create/scheduleMe`;
276
- const response = await axios.post(url, data);
276
+ const response = await axios.post(url, data, {
277
+ headers: { ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG" },
278
+ });
277
279
  if (response.status === 200) {
278
280
  this.tourIsBooked = true;
279
281
  }
@@ -3,10 +3,10 @@ import { customElement, property, state } from "lit/decorators.js";
3
3
  import { classMap } from "lit/directives/class-map.js";
4
4
  import { createRef, ref, Ref } from "lit/directives/ref.js";
5
5
  import Talk from "talkjs";
6
- import { Launcher } from ".";
6
+ import { Launcher } from "./Launcher";
7
7
  import "./Scheduler/tour-scheduler";
8
8
  import Analytics from "../analytics";
9
- import { getChatID } from "../chatID";
9
+ import { createChatID, getChatID } from "../chatID";
10
10
  import createConversation from "../createConversation";
11
11
  import fetchBuildingInfo, { Building } from "../fetchBuildingInfo";
12
12
  import { getTheme, Theme, ThemeIdString } from "../themes";
@@ -145,6 +145,32 @@ export class MEChat extends LitElement {
145
145
  }
146
146
  }
147
147
 
148
+ public async restartConversation(): Promise<void> {
149
+ if (
150
+ !this.analytics ||
151
+ !this.analytics.chatId ||
152
+ !this.building ||
153
+ !this.theme ||
154
+ !this.popup ||
155
+ !MEChat.session
156
+ ) {
157
+ return;
158
+ }
159
+ this.chatId = createChatID(this.orgSlug, this.buildingSlug);
160
+ const session = await MEChat.session;
161
+ this.analytics.chatId = this.chatId;
162
+ this.popup.select(
163
+ createConversation(
164
+ session,
165
+ this.building,
166
+ this.theme,
167
+ this.avatarSrc || this.building.avatarSrc,
168
+ this.chatId,
169
+ this.isMobile
170
+ )
171
+ );
172
+ }
173
+
148
174
  private configureLauncherElement = () => {
149
175
  if (!this.popup || !this.launcherRef.value) {
150
176
  return;
@@ -74,7 +74,7 @@ export const getAvailabilitiesGroupedByDay = async (
74
74
  // TODO: alternative to this: cache the building id when getRawAvailabilities is called. Then I can call the normal methods.
75
75
  export const getAvailabilitiesGroupedByDayCached = async (
76
76
  tourType: TourAvailabilityResponseRankOrderedSupportedTourTypesEnum
77
- ): ReturnType<typeof getAvailabilitiesGroupedByDay> =>
77
+ ): Promise<{ [day: string]: Date[] }> =>
78
78
  getAvailabilitiesGroupedByDay(
79
79
  Object.keys(availabilitiesCache).map(Number)[0],
80
80
  tourType