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/dist/chat-bot-widget.js +22 -22
- package/index.html +5 -3
- package/package.json +1 -1
- package/src/ChatWidget.tsx +2 -2
- package/src/element.tsx +4 -2
- package/src/service.ts +16 -0
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
|
-
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/ss-support-widget@1.0.
|
|
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
package/src/ChatWidget.tsx
CHANGED
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
|
-
|
|
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
|
|