-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.tsx
77 lines (71 loc) · 2.22 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React, { StrictMode, useEffect, useRef, useState } from "react";
import { createRoot } from "react-dom/client";
import { Widget } from "./src/designs/react";
import { HandoffComponent } from "./src/designs/react/components/custom-components/Handoff.component";
const apiUrl = "http://localhost:8080";
const token = import.meta.env.VITE_ORG_TOKEN;
const apiToken = import.meta.env.VITE_ORG_PUBLIC_API_TOKEN;
function App() {
// const [userToken, setUserToken] = useState("");
// const didFetchRef = useRef(false);
// useEffect(() => {
// if (didFetchRef.current) return;
// didFetchRef.current = true;
// fetch("http://localhost:8080/widget/authenticate-user", {
// method: "POST",
// body: JSON.stringify({
// email: "[email protected]",
// }),
// headers: {
// "Content-Type": "application/json",
// Authorization: `Bearer ${apiToken}`,
// },
// }).then(async (res) => {
// const data = await res.json();
// setUserToken(data.token);
// });
// }, []);
// if (!userToken) return null;
return (
<div
data-opencx-widget
style={{ width: "100vw", height: "100vh", backgroundColor: "black" }}
>
<Widget
components={[{ key: "handoff", component: HandoffComponent }]}
options={{
apiUrl,
token,
initialMessages: ["Hi there, how can we help you?"],
// theme: {
// primaryColor: "#639"
// },
// collectUserData: true,
// extraDataCollectionFields: ["Order number"],
// prefillUserData: {
// // name: "ali",
// email: "[email protected]",
// },
// user: {
// // externalId: "xyz",
// // token: userToken,
// data: {
// name: "ali",
// email: "[email protected]",
// },
// },
bot: {
name: "Oppy",
avatar:
"https://framerusercontent.com/images/LKg2ybzxWutds9WSKpqGtaGw.jpg",
},
}}
/>
</div>
);
}
const rootElement = document.getElementById("root");
if (!rootElement) {
throw new Error("No root element found");
}
createRoot(rootElement).render(<App />);