@axos-web-dev/shared-components 1.0.100-dev.35-chatbot-3 → 1.0.100-dev.37

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.
@@ -18,6 +18,7 @@ const Chatbot = ({
18
18
  const clientRef = useRef(null);
19
19
  const menuRef = useRef(null);
20
20
  const isMountedRef = useRef(false);
21
+ const hasLoadedBefore = useRef(true);
21
22
  const chatRef = useRef(null);
22
23
  const agent_virtual = useRef(null);
23
24
  const [status, setStatus] = useState("idle");
@@ -42,7 +43,7 @@ const Chatbot = ({
42
43
  },
43
44
  env: {
44
45
  label: "env",
45
- value: projectEnv
46
+ value: projectEnv === "dev" ? "uat" : projectEnv
46
47
  }
47
48
  }
48
49
  };
@@ -122,7 +123,7 @@ const Chatbot = ({
122
123
  clientRef.current?.off("chat.connected", onChatConnectedHandler);
123
124
  };
124
125
  const createClient = async () => {
125
- if (isMountedRef.current) return;
126
+ if (clientRef.current) return;
126
127
  const client = new Client({
127
128
  companyId: process.env.CCAI_COMPANY_ID || "",
128
129
  tenant: process.env.CCAI_TENANT_NAME || "",
@@ -130,6 +131,7 @@ const Chatbot = ({
130
131
  // or your region
131
132
  authenticate
132
133
  });
134
+ isMountedRef.current = true;
133
135
  clientRef.current = client;
134
136
  menuRef.current = await client.getMenus();
135
137
  console.log("menus:", menuRef.current);
@@ -179,9 +181,11 @@ const Chatbot = ({
179
181
  console.log("Ending chat");
180
182
  if (chatRef.current) {
181
183
  await clientRef.current?.finishChat();
184
+ await chatRef.current.destroy();
182
185
  clearMessages();
183
186
  chatRef.current = null;
184
187
  console.log("Chat ended");
188
+ setHasStarted(false);
185
189
  reset();
186
190
  }
187
191
  };
@@ -195,6 +199,7 @@ const Chatbot = ({
195
199
  console.log("Chatbot unmounted");
196
200
  deregisterEventHandlers();
197
201
  isMountedRef.current = false;
202
+ hasLoadedBefore.current = true;
198
203
  });
199
204
  return /* @__PURE__ */ jsxs("div", { children: [
200
205
  /* @__PURE__ */ jsx(Bubble, { onClick: handleClick }),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@axos-web-dev/shared-components",
3
3
  "description": "Axos shared components library for web.",
4
- "version": "1.0.100-dev.35-chatbot-3",
4
+ "version": "1.0.100-dev.37",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",