create-dovite 2.0.0 → 2.2.0
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/README.md +20 -16
- package/index.js +10 -4
- package/package.json +7 -3
- package/src/files.js +111 -0
- package/src/prompts.js +52 -0
- package/src/setup.js +129 -0
- package/templates/react-js/jsconfig.json +7 -0
- package/templates/react-js/public/manifest.json +12 -0
- package/templates/react-js/public/thumbnail.png +0 -0
- package/templates/react-js/src/API/currentUserContext.jsx +56 -0
- package/templates/react-js/src/API/dataApi.js +235 -0
- package/templates/react-js/src/API/domoAPI.js +311 -0
- package/templates/react-js/src/App.jsx +7 -0
- package/templates/react-js/src/index.css +1 -0
- package/templates/react-js/src/pages/index.css +96 -0
- package/templates/react-js/src/pages/index.jsx +340 -0
- package/templates/react-js/vite.config.js +40 -0
- package/templates/react-ts/public/manifest.json +12 -0
- package/templates/react-ts/public/thumbnail.png +0 -0
- package/templates/react-ts/src/API/currentUserContext.tsx +66 -0
- package/templates/react-ts/src/API/dataApi.ts +338 -0
- package/templates/react-ts/src/API/domoAPI.ts +355 -0
- package/templates/react-ts/src/App.tsx +7 -0
- package/templates/react-ts/src/index.css +1 -0
- package/templates/react-ts/src/pages/index.css +96 -0
- package/templates/react-ts/src/pages/index.tsx +347 -0
- package/templates/react-ts/tsconfig.app.json +31 -0
- package/templates/react-ts/tsconfig.json +17 -0
- package/templates/react-ts/vite.config.ts +47 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { Button } from "../components/ui/button";
|
|
3
|
+
import { FiBook, FiPackage, FiGithub, FiExternalLink } from "react-icons/fi";
|
|
4
|
+
import "./index.css";
|
|
5
|
+
|
|
6
|
+
// Vite Logo SVG
|
|
7
|
+
const ViteLogo = () => (
|
|
8
|
+
<svg
|
|
9
|
+
className="logo-icon logo-vite"
|
|
10
|
+
viewBox="0 0 410 404"
|
|
11
|
+
fill="none"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z"
|
|
16
|
+
fill="url(#paint0_linear)"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z"
|
|
20
|
+
fill="url(#paint1_linear)"
|
|
21
|
+
/>
|
|
22
|
+
<defs>
|
|
23
|
+
<linearGradient
|
|
24
|
+
id="paint0_linear"
|
|
25
|
+
x1="6.00017"
|
|
26
|
+
y1="32.9999"
|
|
27
|
+
x2="235"
|
|
28
|
+
y2="344"
|
|
29
|
+
gradientUnits="userSpaceOnUse"
|
|
30
|
+
>
|
|
31
|
+
<stop stopColor="#41D1FF" />
|
|
32
|
+
<stop offset="1" stopColor="#BD34FE" />
|
|
33
|
+
</linearGradient>
|
|
34
|
+
<linearGradient
|
|
35
|
+
id="paint1_linear"
|
|
36
|
+
x1="194.651"
|
|
37
|
+
y1="8.81818"
|
|
38
|
+
x2="236.076"
|
|
39
|
+
y2="292.989"
|
|
40
|
+
gradientUnits="userSpaceOnUse"
|
|
41
|
+
>
|
|
42
|
+
<stop stopColor="#FFBD4F" />
|
|
43
|
+
<stop offset="1" stopColor="#FF980E" />
|
|
44
|
+
</linearGradient>
|
|
45
|
+
</defs>
|
|
46
|
+
</svg>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// React Logo SVG
|
|
50
|
+
const ReactLogo = () => (
|
|
51
|
+
<svg
|
|
52
|
+
className="logo-icon logo-react"
|
|
53
|
+
viewBox="-11.5 -10.23174 23 20.46348"
|
|
54
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
55
|
+
>
|
|
56
|
+
<circle cx="0" cy="0" r="2.05" fill="#61dafb" />
|
|
57
|
+
<g stroke="#61dafb" strokeWidth="1" fill="none">
|
|
58
|
+
<ellipse rx="11" ry="4.2" />
|
|
59
|
+
<ellipse rx="11" ry="4.2" transform="rotate(60)" />
|
|
60
|
+
<ellipse rx="11" ry="4.2" transform="rotate(120)" />
|
|
61
|
+
</g>
|
|
62
|
+
</svg>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// Domo Logo SVG
|
|
66
|
+
const DomoLogo = () => (
|
|
67
|
+
<svg
|
|
68
|
+
className="logo-icon logo-domo"
|
|
69
|
+
viewBox="0 0 100 100"
|
|
70
|
+
fill="none"
|
|
71
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
72
|
+
>
|
|
73
|
+
<rect width="100" height="100" rx="16" fill="url(#domoGradient)" />
|
|
74
|
+
<text
|
|
75
|
+
x="50"
|
|
76
|
+
y="65"
|
|
77
|
+
textAnchor="middle"
|
|
78
|
+
fill="white"
|
|
79
|
+
fontSize="36"
|
|
80
|
+
fontWeight="bold"
|
|
81
|
+
fontFamily="Arial, sans-serif"
|
|
82
|
+
>
|
|
83
|
+
DOMO
|
|
84
|
+
</text>
|
|
85
|
+
{/* <circle cx="72" cy="35" r="8" fill="white" opacity="0.8" /> */}
|
|
86
|
+
<defs>
|
|
87
|
+
<linearGradient
|
|
88
|
+
id="domoGradient"
|
|
89
|
+
x1="0"
|
|
90
|
+
y1="0"
|
|
91
|
+
x2="100"
|
|
92
|
+
y2="100"
|
|
93
|
+
gradientUnits="userSpaceOnUse"
|
|
94
|
+
>
|
|
95
|
+
<stop stopColor="#00B5E2" />
|
|
96
|
+
<stop offset="1" stopColor="#0072BC" />
|
|
97
|
+
</linearGradient>
|
|
98
|
+
</defs>
|
|
99
|
+
</svg>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Tailwind Logo SVG
|
|
103
|
+
const TailwindLogo = () => (
|
|
104
|
+
<svg
|
|
105
|
+
className="logo-icon logo-tailwind"
|
|
106
|
+
viewBox="0 0 54 33"
|
|
107
|
+
fill="none"
|
|
108
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
109
|
+
>
|
|
110
|
+
<g clipPath="url(#tailwindClip)">
|
|
111
|
+
<path
|
|
112
|
+
fillRule="evenodd"
|
|
113
|
+
clipRule="evenodd"
|
|
114
|
+
d="M27 0C19.8 0 15.3 3.6 13.5 10.8C16.2 7.2 19.35 5.85 22.95 6.75C25.004 7.263 26.472 8.754 28.097 10.403C30.744 13.09 33.808 16.2 40.5 16.2C47.7 16.2 52.2 12.6 54 5.4C51.3 9 48.15 10.35 44.55 9.45C42.496 8.937 41.028 7.446 39.403 5.797C36.756 3.11 33.692 0 27 0ZM13.5 16.2C6.3 16.2 1.8 19.8 0 27C2.7 23.4 5.85 22.05 9.45 22.95C11.504 23.464 12.972 24.954 14.597 26.603C17.244 29.29 20.308 32.4 27 32.4C34.2 32.4 38.7 28.8 40.5 21.6C37.8 25.2 34.65 26.55 31.05 25.65C28.996 25.137 27.528 23.646 25.903 21.997C23.256 19.31 20.192 16.2 13.5 16.2Z"
|
|
115
|
+
fill="url(#tailwindGradient)"
|
|
116
|
+
/>
|
|
117
|
+
</g>
|
|
118
|
+
<defs>
|
|
119
|
+
<linearGradient
|
|
120
|
+
id="tailwindGradient"
|
|
121
|
+
x1="0"
|
|
122
|
+
y1="16.2"
|
|
123
|
+
x2="54"
|
|
124
|
+
y2="16.2"
|
|
125
|
+
gradientUnits="userSpaceOnUse"
|
|
126
|
+
>
|
|
127
|
+
<stop stopColor="#06B6D4" />
|
|
128
|
+
<stop offset="1" stopColor="#22D3EE" />
|
|
129
|
+
</linearGradient>
|
|
130
|
+
<clipPath id="tailwindClip">
|
|
131
|
+
<rect width="54" height="33" fill="white" />
|
|
132
|
+
</clipPath>
|
|
133
|
+
</defs>
|
|
134
|
+
</svg>
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Shadcn Logo SVG
|
|
138
|
+
const ShadcnLogo = () => (
|
|
139
|
+
<svg
|
|
140
|
+
className="logo-icon logo-shadcn"
|
|
141
|
+
viewBox="0 0 256 256"
|
|
142
|
+
fill="none"
|
|
143
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
144
|
+
>
|
|
145
|
+
<rect width="256" height="256" rx="60" fill="currentColor" />
|
|
146
|
+
<line
|
|
147
|
+
x1="208"
|
|
148
|
+
y1="128"
|
|
149
|
+
x2="128"
|
|
150
|
+
y2="208"
|
|
151
|
+
stroke="url(#shadcnGradient)"
|
|
152
|
+
strokeWidth="24"
|
|
153
|
+
strokeLinecap="round"
|
|
154
|
+
/>
|
|
155
|
+
<line
|
|
156
|
+
x1="192"
|
|
157
|
+
y1="40"
|
|
158
|
+
x2="40"
|
|
159
|
+
y2="192"
|
|
160
|
+
stroke="url(#shadcnGradient)"
|
|
161
|
+
strokeWidth="24"
|
|
162
|
+
strokeLinecap="round"
|
|
163
|
+
/>
|
|
164
|
+
<defs>
|
|
165
|
+
<linearGradient
|
|
166
|
+
id="shadcnGradient"
|
|
167
|
+
x1="40"
|
|
168
|
+
y1="40"
|
|
169
|
+
x2="208"
|
|
170
|
+
y2="208"
|
|
171
|
+
gradientUnits="userSpaceOnUse"
|
|
172
|
+
>
|
|
173
|
+
<stop stopColor="#fff" />
|
|
174
|
+
<stop offset="1" stopColor="#a1a1aa" />
|
|
175
|
+
</linearGradient>
|
|
176
|
+
</defs>
|
|
177
|
+
</svg>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const DefaultPage = () => {
|
|
181
|
+
const [count, setCount] = useState(0);
|
|
182
|
+
|
|
183
|
+
const docLinks = [
|
|
184
|
+
{
|
|
185
|
+
title: "DOMO APIs",
|
|
186
|
+
url: "https://developer.domo.com/portal/8ba9aedad3679-ap-is",
|
|
187
|
+
description: "Explore the API documentation",
|
|
188
|
+
Icon: FiBook,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
title: "Domo Starter Kit",
|
|
192
|
+
url: "https://developer.domo.com/portal/u8w475o2245yp-starter-kits",
|
|
193
|
+
description: "Get started quickly",
|
|
194
|
+
Icon: FiPackage,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
title: "GitHub Repository",
|
|
198
|
+
url: "https://github.com/Ajay-Balu/create-dovite",
|
|
199
|
+
description: "View source code",
|
|
200
|
+
Icon: FiGithub,
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<div className="landing-page h-screen w-screen flex flex-col overflow-hidden">
|
|
206
|
+
{/* Main Content Area */}
|
|
207
|
+
<div className="flex-1 flex items-center justify-center gap-16 px-8 py-8 max-w-[1400px] mx-auto w-full max-lg:flex-col max-lg:gap-8 max-lg:overflow-y-auto">
|
|
208
|
+
{/* Left Side - Hero Section */}
|
|
209
|
+
<div className="flex-1 flex flex-col items-center justify-center text-center gap-4">
|
|
210
|
+
{/* Logo Container */}
|
|
211
|
+
<div className="flex justify-center items-center gap-2 flex-wrap mb-2">
|
|
212
|
+
<a
|
|
213
|
+
href="https://vitejs.dev"
|
|
214
|
+
target="_blank"
|
|
215
|
+
rel="noopener noreferrer"
|
|
216
|
+
className="inline-flex transition-transform duration-300 hover:scale-115"
|
|
217
|
+
>
|
|
218
|
+
<ViteLogo />
|
|
219
|
+
</a>
|
|
220
|
+
<span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
|
|
221
|
+
<a
|
|
222
|
+
href="https://react.dev"
|
|
223
|
+
target="_blank"
|
|
224
|
+
rel="noopener noreferrer"
|
|
225
|
+
className="inline-flex transition-transform duration-300 hover:scale-115"
|
|
226
|
+
>
|
|
227
|
+
<ReactLogo />
|
|
228
|
+
</a>
|
|
229
|
+
<span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
|
|
230
|
+
<a
|
|
231
|
+
href="https://www.domo.com"
|
|
232
|
+
target="_blank"
|
|
233
|
+
rel="noopener noreferrer"
|
|
234
|
+
className="inline-flex transition-transform duration-300 hover:scale-115"
|
|
235
|
+
>
|
|
236
|
+
<DomoLogo />
|
|
237
|
+
</a>
|
|
238
|
+
<span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
|
|
239
|
+
<a
|
|
240
|
+
href="https://tailwindcss.com"
|
|
241
|
+
target="_blank"
|
|
242
|
+
rel="noopener noreferrer"
|
|
243
|
+
className="inline-flex transition-transform duration-300 hover:scale-115"
|
|
244
|
+
>
|
|
245
|
+
<TailwindLogo />
|
|
246
|
+
</a>
|
|
247
|
+
<span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
|
|
248
|
+
<a
|
|
249
|
+
href="https://ui.shadcn.com"
|
|
250
|
+
target="_blank"
|
|
251
|
+
rel="noopener noreferrer"
|
|
252
|
+
className="inline-flex transition-transform duration-300 hover:scale-115"
|
|
253
|
+
>
|
|
254
|
+
<ShadcnLogo />
|
|
255
|
+
</a>
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
{/* Title */}
|
|
259
|
+
<h1 className="text-5xl font-extrabold tracking-tight m-0 leading-tight max-md:text-4xl max-sm:text-3xl">
|
|
260
|
+
<span className="gradient-text">Dovite</span>
|
|
261
|
+
</h1>
|
|
262
|
+
<p className="text-base text-zinc-400 m-0 font-medium">
|
|
263
|
+
Vite + React + DOMO + Tailwind + Shadcn/UI
|
|
264
|
+
</p>
|
|
265
|
+
<p className="text-sm text-zinc-500 m-0 max-w-[400px]">
|
|
266
|
+
Build beautiful DOMO apps with modern web technologies
|
|
267
|
+
</p>
|
|
268
|
+
|
|
269
|
+
{/* Interactive Demo Section */}
|
|
270
|
+
<div className="mt-6">
|
|
271
|
+
<div className="px-8 py-6 bg-white/3 border border-white/8 rounded-2xl backdrop-blur-lg">
|
|
272
|
+
<Button
|
|
273
|
+
onClick={() => setCount((count) => count + 1)}
|
|
274
|
+
className="text-sm px-5 py-2.5 transition-all duration-300 hover:-translate-y-0.5 hover:shadow-xl"
|
|
275
|
+
>
|
|
276
|
+
Count is {count}
|
|
277
|
+
</Button>
|
|
278
|
+
<p className="mt-4 text-zinc-500 text-xs">
|
|
279
|
+
Edit{" "}
|
|
280
|
+
<code className="bg-zinc-500/15 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[0.8em]">
|
|
281
|
+
src/pages/index.jsx
|
|
282
|
+
</code>{" "}
|
|
283
|
+
and save to test HMR
|
|
284
|
+
</p>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
{/* Right Side - Documentation Links */}
|
|
290
|
+
<div className="w-80 flex flex-col gap-4 p-6 bg-white/2 border border-white/6 rounded-2xl backdrop-blur-lg max-lg:w-full max-lg:max-w-[400px]">
|
|
291
|
+
<h2 className="text-xs font-semibold text-zinc-400 uppercase tracking-widest m-0 pb-3 border-b border-white/6">
|
|
292
|
+
Resources
|
|
293
|
+
</h2>
|
|
294
|
+
<div className="flex flex-col gap-2">
|
|
295
|
+
{docLinks.map((link, index) => (
|
|
296
|
+
<a
|
|
297
|
+
key={index}
|
|
298
|
+
href={link.url}
|
|
299
|
+
target="_blank"
|
|
300
|
+
rel="noopener noreferrer"
|
|
301
|
+
className="group flex items-center gap-3 px-4 py-3.5 bg-white/2 border border-white/4 rounded-xl no-underline text-inherit transition-all duration-250 hover:bg-white/6 hover:border-cyan-500/30 hover:translate-x-1"
|
|
302
|
+
>
|
|
303
|
+
<link.Icon className="text-xl text-cyan-500 shrink-0" />
|
|
304
|
+
<div className="flex-1 flex flex-col gap-0.5 min-w-0">
|
|
305
|
+
<span className="text-sm font-semibold text-zinc-100">
|
|
306
|
+
{link.title}
|
|
307
|
+
</span>
|
|
308
|
+
<span className="text-xs text-zinc-500">
|
|
309
|
+
{link.description}
|
|
310
|
+
</span>
|
|
311
|
+
</div>
|
|
312
|
+
<FiExternalLink className="text-sm text-zinc-600 shrink-0 transition-all duration-250 group-hover:text-cyan-500 group-hover:translate-x-0.5 group-hover:-translate-y-0.5" />
|
|
313
|
+
</a>
|
|
314
|
+
))}
|
|
315
|
+
</div>
|
|
316
|
+
<p className="text-xs text-zinc-600 text-center m-0 pt-2">
|
|
317
|
+
Click on the logos to learn more
|
|
318
|
+
</p>
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
{/* Footer */}
|
|
323
|
+
<footer className="px-8 py-4 text-center border-t border-white/6 bg-black/20">
|
|
324
|
+
<p className="m-0 text-zinc-600 text-xs">
|
|
325
|
+
Built with <span className="text-red-500">❤</span> using{" "}
|
|
326
|
+
<a
|
|
327
|
+
href="https://github.com/Ajay-Balu/create-dovite"
|
|
328
|
+
target="_blank"
|
|
329
|
+
rel="noopener noreferrer"
|
|
330
|
+
className="text-cyan-500 no-underline font-medium transition-colors duration-300 hover:text-purple-500"
|
|
331
|
+
>
|
|
332
|
+
create-dovite
|
|
333
|
+
</a>
|
|
334
|
+
</p>
|
|
335
|
+
</footer>
|
|
336
|
+
</div>
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export default DefaultPage;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { Proxy } from "@domoinc/ryuu-proxy";
|
|
5
|
+
import manifest from "./public/manifest.json";
|
|
6
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
7
|
+
|
|
8
|
+
const config = { manifest };
|
|
9
|
+
const proxy = new Proxy(config);
|
|
10
|
+
|
|
11
|
+
// https://vite.dev/config/
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
plugins: [
|
|
14
|
+
react(),
|
|
15
|
+
tailwindcss(),
|
|
16
|
+
{
|
|
17
|
+
name: "ryuu-proxy",
|
|
18
|
+
configureServer(server) {
|
|
19
|
+
server.middlewares.use((req, res, next) => {
|
|
20
|
+
res.status = function (code) {
|
|
21
|
+
this.statusCode = code;
|
|
22
|
+
return this;
|
|
23
|
+
};
|
|
24
|
+
res.send = function (body) {
|
|
25
|
+
this.setHeader("Content-Type", "text/plain");
|
|
26
|
+
this.end(body);
|
|
27
|
+
};
|
|
28
|
+
next();
|
|
29
|
+
});
|
|
30
|
+
server.middlewares.use(proxy.express());
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
define: { "process.env": {} },
|
|
35
|
+
resolve: {
|
|
36
|
+
alias: {
|
|
37
|
+
"@": path.resolve(__dirname, "./src"),
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import { createContext, useState, useEffect, ReactNode } from "react";
|
|
4
|
+
import DomoApi from "./domoAPI";
|
|
5
|
+
|
|
6
|
+
export interface UserContextType {
|
|
7
|
+
currentUser: string;
|
|
8
|
+
currentUserId: string;
|
|
9
|
+
avatarKey: string;
|
|
10
|
+
customer: string;
|
|
11
|
+
host: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const UserContext = createContext<UserContextType | undefined>(
|
|
15
|
+
undefined
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const UserProvider = ({ children }: { children: ReactNode }) => {
|
|
19
|
+
const [currentUser, setCurrentUser] = useState<string>("");
|
|
20
|
+
const [currentUserId, setCurrentUserId] = useState<string>("");
|
|
21
|
+
const [avatarKey, setAvatarKey] = useState<string>("");
|
|
22
|
+
const [customer, setCustomer] = useState<string>("");
|
|
23
|
+
const [host, setHost] = useState<string>("");
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let isUserFetched = false;
|
|
27
|
+
|
|
28
|
+
DomoApi.GetCurrentUser().then((data: any) => {
|
|
29
|
+
// console.log("User Data",data);
|
|
30
|
+
|
|
31
|
+
if (!isUserFetched) {
|
|
32
|
+
const userId = data?.userId;
|
|
33
|
+
const displayName = data?.displayName;
|
|
34
|
+
const avatarKey = data?.avatarKey;
|
|
35
|
+
const customer = data?.customer;
|
|
36
|
+
const host = data?.host;
|
|
37
|
+
|
|
38
|
+
setCurrentUser(displayName || "");
|
|
39
|
+
setCurrentUserId(userId || "");
|
|
40
|
+
setAvatarKey(avatarKey || "");
|
|
41
|
+
setCustomer(customer || "");
|
|
42
|
+
setHost(host || "");
|
|
43
|
+
|
|
44
|
+
isUserFetched = true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
isUserFetched = true;
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<UserContext.Provider
|
|
55
|
+
value={{
|
|
56
|
+
currentUser,
|
|
57
|
+
currentUserId,
|
|
58
|
+
avatarKey,
|
|
59
|
+
customer,
|
|
60
|
+
host,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</UserContext.Provider>
|
|
65
|
+
);
|
|
66
|
+
};
|