ss-support-widget 1.0.3 → 1.0.5

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/index.html CHANGED
@@ -4,14 +4,16 @@
4
4
  <meta charset="utf-8" />
5
5
  <title>Widget test</title>
6
6
  </head>
7
- <body>
7
+ <body style="height: 100vh;">
8
+ <div style="height: 600px;">test</div>
9
+ <div style="height: 600px;">test</div>
8
10
  <script>
9
11
  window.ChatBotConfig = {
10
12
  clientId: "694802ab424bd274310d61d8",
11
13
  apiBaseUrl: "https://ai-chatbots-api.azurewebsites.net/",
12
14
  };
13
15
  </script>
14
- <!-- <script type="module" src="/src/element.tsx"></script> -->
15
- <script src="https://cdn.jsdelivr.net/npm/ss-support-widget@1.0.2/dist/chat-bot-widget.js"></script>
16
+ <script type="module" src="/src/element.tsx"></script>
17
+ <!-- <script src="https://cdn.jsdelivr.net/npm/ss-support-widget@1.0.4/dist/chat-bot-widget.js"></script> -->
16
18
  </body>
17
19
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ss-support-widget",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Chatbot widget for customer support",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -149,9 +149,9 @@ export function ChatWidget({
149
149
  <Box
150
150
  sx={{
151
151
  flex: 1,
152
- minHeight: 0,
152
+ minHeight: 250,
153
153
  position: "relative",
154
- height: 400,
154
+ // height: 300,
155
155
  overflow: "auto",
156
156
  px: 1.5,
157
157
  py: 1.5,
package/src/element.tsx CHANGED
@@ -5,7 +5,7 @@ import { CacheProvider } from "@emotion/react";
5
5
  import { CssBaseline, ThemeProvider, createTheme } from "@mui/material";
6
6
  import App from "./App";
7
7
  import { ensureViewportMeta } from "./hooks";
8
- import { getApiStatus, getHideChatForUrls } from "./service";
8
+ import { getApiStatus, getClientActivityStatus, getHideChatForUrls } from "./service";
9
9
 
10
10
  export type Config = {
11
11
  clientId: string;
@@ -89,8 +89,10 @@ if (!customElements.get(chatBotComponentName)) {
89
89
  if (document.querySelector(chatBotComponentName)) return;
90
90
 
91
91
  var isHealty = await getApiStatus(cfg)
92
+ if (!isHealty) return;
92
93
 
93
- if(!isHealty) return;
94
+ var isClientActive = await getClientActivityStatus(cfg)
95
+ if (!isClientActive) return;
94
96
 
95
97
  cfg.hideChatForUrls = await getHideChatForUrls(cfg)
96
98
  const el = document.createElement(chatBotComponentName);
package/src/service.ts CHANGED
@@ -37,6 +37,22 @@ export async function getApiStatus(config: Config): Promise<boolean> {
37
37
  return res.ok;
38
38
  }
39
39
 
40
+ export async function getClientActivityStatus(config: Config): Promise<boolean> {
41
+
42
+ const res = await fetch(config.apiBaseUrl + "api/client-activity-status", {
43
+ method: "GET",
44
+ headers: {
45
+ "Content-Type": "application/json",
46
+ ...(config.clientId ? { "X-Client-Id": config.clientId } : {}),
47
+ },
48
+ });
49
+
50
+ if (!res.ok) {
51
+ return false;
52
+ }
53
+
54
+ return res.body ? await res.json() as boolean : false;
55
+ }
40
56
 
41
57
  export async function getHideChatForUrls(config: Config): Promise<string[]> {
42
58