@shop-prompter/react 0.1.1

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.
@@ -0,0 +1,728 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { useState, useEffect } from "react";
4
+ import { ShopPrompterService } from "./shop-prompter.service";
5
+ const styles = {
6
+ header: {
7
+ display: "flex",
8
+ alignItems: "center",
9
+ justifyContent: "space-between",
10
+ padding: "16px",
11
+ },
12
+ subHeaderContainer: {
13
+ display: "flex",
14
+ alignItems: "center",
15
+ gap: "0.5rem",
16
+ },
17
+ headerButton: {
18
+ fontSize: "0.75rem",
19
+ color: "#71717a",
20
+ padding: "0.25rem 0.5rem",
21
+ borderRadius: "0.25rem",
22
+ backgroundColor: "transparent",
23
+ border: "none",
24
+ cursor: "pointer",
25
+ transition: "background-color 0.2s, color 0.2s",
26
+ onHover: {
27
+ backgroundColor: "hsl(220 14% 96%)",
28
+ color: "hsl(220 13% 13%)",
29
+ },
30
+ },
31
+ headerText: {
32
+ color: "hsl(220 13% 13%)",
33
+ fontWeight: 600,
34
+ },
35
+ button: {
36
+ padding: "0.625rem 1rem",
37
+ border: "1px solid #e5e7eb",
38
+ borderRadius: "0.75rem",
39
+ backgroundColor: "transparent",
40
+ transition: "background-color 0.2s, color 0.2s",
41
+ display: "flex",
42
+ alignItems: "center",
43
+ gap: "0.5rem",
44
+ cursor: "pointer",
45
+ fontSize: "0.875rem",
46
+ color: "#09090b",
47
+ },
48
+ ButtonSheetButton: {
49
+ color: "#6b7280",
50
+ backgroundColor: "transparent",
51
+ border: "none",
52
+ cursor: "pointer",
53
+ padding: "0.25rem",
54
+ fontSize: "1.25rem",
55
+ transition: "color 0.2s",
56
+ },
57
+ chatContainer: {
58
+ flex: 1,
59
+ overflowY: "auto",
60
+ padding: "1rem",
61
+ backgroundColor: "white",
62
+ },
63
+ welcomeContainer: {
64
+ textAlign: "center",
65
+ paddingTop: "3rem",
66
+ paddingBottom: "3rem",
67
+ display: "flex",
68
+ flexDirection: "column",
69
+ alignItems: "center",
70
+ },
71
+ welcomeTitle: {
72
+ color: "#111827",
73
+ marginBottom: "0.5rem",
74
+ fontFamily: 'var(--font-space-grotesk), "Space Grotesk", sans-serif',
75
+ fontWeight: 500,
76
+ fontStyle: "Medium",
77
+ fontSize: "32px",
78
+ leadingTrim: "NONE",
79
+ lineHeight: "100%",
80
+ letterSpacing: "0%",
81
+ textAlign: "center",
82
+ },
83
+ welcomeDescription: {
84
+ color: "#4b5563",
85
+ maxWidth: "20rem",
86
+ fontFamily: 'var(--font-space-grotesk), "Space Grotesk", sans-serif',
87
+ fontWeight: 400,
88
+ fontStyle: "Regular",
89
+ fontSize: "16px",
90
+ leadingTrim: "NONE",
91
+ lineHeight: "100%",
92
+ letterSpacing: "0%",
93
+ textAlign: "center",
94
+ },
95
+ buttonContainer: {
96
+ marginTop: "2rem",
97
+ display: "flex",
98
+ flexWrap: "wrap",
99
+ justifyContent: "center",
100
+ gap: "0.5rem",
101
+ },
102
+ messageContainerUser: {
103
+ display: "flex",
104
+ flexDirection: "column",
105
+ alignItems: "flex-end",
106
+ },
107
+ messageContainerAssistant: {
108
+ display: "flex",
109
+ flexDirection: "column",
110
+ alignItems: "flex-start",
111
+ },
112
+ messageBubbleUser: {
113
+ backgroundColor: "#111827",
114
+ color: "white",
115
+ borderRadius: "1rem",
116
+ borderTopRightRadius: "0",
117
+ padding: "0.5rem 1rem",
118
+ fontSize: "0.875rem",
119
+ boxShadow: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
120
+ maxWidth: "85%",
121
+ },
122
+ messageBubbleAssistant: {
123
+ backgroundColor: "#f3f4f6",
124
+ color: "#1f2937",
125
+ borderRadius: "1rem",
126
+ borderTopLeftRadius: "0",
127
+ padding: "0.5rem 1rem",
128
+ fontSize: "0.875rem",
129
+ boxShadow: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
130
+ maxWidth: "85%",
131
+ },
132
+ thinkingIndicator: {
133
+ display: "flex",
134
+ alignItems: "center",
135
+ gap: "0.5rem",
136
+ fontStyle: "italic",
137
+ color: "#6b7280",
138
+ },
139
+ productCardsContainer: {
140
+ marginTop: "1rem",
141
+ display: "flex",
142
+ gap: "0.75rem",
143
+ overflowX: "auto",
144
+ width: "100%",
145
+ paddingBottom: "0.5rem",
146
+ },
147
+ productCard: {
148
+ minWidth: "8rem",
149
+ backgroundColor: "white",
150
+ border: "1px solid #e5e7eb",
151
+ borderRadius: "0.75rem",
152
+ overflow: "hidden",
153
+ boxShadow: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
154
+ display: "flex",
155
+ flexDirection: "column",
156
+ },
157
+ productImageContainer: {
158
+ height: "6rem",
159
+ backgroundColor: "#f9fafb",
160
+ display: "flex",
161
+ alignItems: "center",
162
+ justifyContent: "center",
163
+ padding: "0.5rem",
164
+ },
165
+ productInfo: {
166
+ padding: "0.5rem",
167
+ },
168
+ productSku: {
169
+ fontSize: "0.75rem",
170
+ fontWeight: 600,
171
+ overflow: "hidden",
172
+ textOverflow: "ellipsis",
173
+ whiteSpace: "nowrap",
174
+ color: "#111827",
175
+ },
176
+ productLink: {
177
+ fontSize: "0.625rem",
178
+ color: "#2563eb",
179
+ fontWeight: "bold",
180
+ textDecoration: "none",
181
+ },
182
+ errorContainer: {
183
+ padding: "0.75rem",
184
+ backgroundColor: "#fef2f2",
185
+ border: "1px solid #fecaca",
186
+ color: "#dc2626",
187
+ fontSize: "0.75rem",
188
+ borderRadius: "0.5rem",
189
+ },
190
+ inputSection: {
191
+ padding: "1rem",
192
+ borderTop: "1px solid #e5e7eb",
193
+ backgroundColor: "#f9fafb",
194
+ },
195
+ inputWrapper: {
196
+ display: "flex",
197
+ alignItems: "center",
198
+ gap: "0.5rem",
199
+ backgroundColor: "white",
200
+ border: "1px solid #d1d5db",
201
+ borderRadius: "0.75rem",
202
+ padding: "0.5rem 1rem",
203
+ transition: "all 0.2s",
204
+ },
205
+ input: {
206
+ flex: 1,
207
+ backgroundColor: "transparent",
208
+ border: "none",
209
+ outline: "none",
210
+ fontSize: "0.875rem",
211
+ color: "#111827",
212
+ padding: "0.25rem 0",
213
+ },
214
+ formButton: {
215
+ backgroundColor: "transparent",
216
+ color: "white",
217
+ width: "32px",
218
+ height: "32px",
219
+ borderRadius: "0.5rem",
220
+ padding: 0,
221
+ fontSize: "0.75rem",
222
+ fontWeight: "bold",
223
+ border: "none",
224
+ cursor: "pointer",
225
+ transition: "background-color 0.2s",
226
+ },
227
+ sendButton: {
228
+ backgroundColor: "#AD59FF1A",
229
+ },
230
+ disclaimer: {
231
+ fontSize: "0.625rem",
232
+ color: "#9ca3af",
233
+ textAlign: "center",
234
+ marginTop: "0.75rem",
235
+ },
236
+ };
237
+ const TRANSLATIONS = {
238
+ newChat: "New Chat",
239
+ welcomeToShopPrompter: "Welcome to ShopPrompter",
240
+ welcomeDescription:
241
+ "I am your personal AI shopping assistant. Ask me anything about our products!",
242
+ askMeAnything: "Ask me anything...",
243
+ thinking: "Thinking...",
244
+ showPopularItems: "Show popular items",
245
+ compareProducts: "Compare products",
246
+ findByBudget: "Find by budget",
247
+ };
248
+ const ICONS = {
249
+ chat: "https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/message-square.svg",
250
+ shopprompter:
251
+ "https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/bot.svg",
252
+ popularitems:
253
+ "https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/fire.svg",
254
+ compareproducts:
255
+ "https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/box.svg",
256
+ findbybudget:
257
+ "https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/foto.svg",
258
+ sendHorizontal:
259
+ "https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/send-horizontal.svg",
260
+ };
261
+
262
+ function ShopPrompter(props) {
263
+ const [input, setInput] = useState(() => "");
264
+
265
+ const [isLoading, setIsLoading] = useState(() => false);
266
+
267
+ const [error, setError] = useState(() => null);
268
+
269
+ const [chatMessages, setChatMessages] = useState(() => []);
270
+
271
+ const [showChat, setShowChat] = useState(
272
+ () =>
273
+ props.chatPosition === "right-panel" || props.chatPosition === "full-page"
274
+ );
275
+
276
+ const [service, setService] = useState(() => null);
277
+
278
+ const [isHeaderButtonHovered, setIsHeaderButtonHovered] = useState(
279
+ () => false
280
+ );
281
+
282
+ const [agentExperience, setAgentExperience] = useState(() => null);
283
+
284
+ function containerStyle() {
285
+ const pos = props.chatPosition || "classic-chatbot";
286
+ const isFull = pos === "full-page";
287
+ const isBottom = pos === "bottom-sheet";
288
+ const isClassic = pos === "classic-chatbot";
289
+ const isRight = pos === "right-panel";
290
+ return {
291
+ position: isFull ? "relative" : "fixed",
292
+ bottom: isClassic ? "1rem" : isBottom ? "2rem" : "0",
293
+ right: isClassic || isRight ? "1rem" : "0",
294
+ width: isFull ? "100%" : isBottom ? "90%" : "24rem",
295
+ height: isClassic ? "550px" : isBottom ? "700px" : "100%",
296
+ maxWidth: isBottom ? "900px" : "none",
297
+ left: isBottom ? "50%" : "auto",
298
+ transform: isBottom ? "translateX(-50%)" : "none",
299
+ zIndex: 50,
300
+ backgroundColor: "white",
301
+ display: "flex",
302
+ flexDirection: "column",
303
+ overflow: "hidden",
304
+ borderRadius: isFull ? "0" : "0.5rem",
305
+ border: isFull ? "none" : "1px solid #e5e7eb",
306
+ boxShadow: isFull ? "none" : "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
307
+ };
308
+ }
309
+
310
+ function containerClass() {
311
+ const pos = props.chatPosition || "classic-chatbot";
312
+ if (pos === "classic-chatbot") return "sh-classic";
313
+ if (pos === "right-panel") return "sh-right";
314
+ if (pos === "bottom-sheet") return "sh-bottom";
315
+ return "sh-full";
316
+ }
317
+
318
+ function messages() {
319
+ return chatMessages.map((msg) => ({
320
+ ...msg,
321
+ safeProductSkus: msg.productSkus || [],
322
+ }));
323
+ }
324
+
325
+ function showWelcome() {
326
+ return chatMessages.length === 0;
327
+ }
328
+
329
+ function getProductImageUrl(sku) {
330
+ return "https://placehold.co/100x100?text=" + sku;
331
+ }
332
+
333
+ function getProductLink(sku) {
334
+ return "/product/" + sku;
335
+ }
336
+
337
+ function handleSend() {
338
+ if (!input.trim() || isLoading) return;
339
+ const userQuery = input;
340
+ setInput("");
341
+ const userMsg = {
342
+ id: Date.now().toString() + "-user",
343
+ role: "user",
344
+ content: userQuery,
345
+ productSkus: [],
346
+ };
347
+ setChatMessages([...chatMessages, userMsg]);
348
+ const assistantMsg = {
349
+ id: Date.now().toString() + "-assistant",
350
+ role: "assistant",
351
+ content: "",
352
+ productSkus: [],
353
+ };
354
+ setChatMessages([...chatMessages, assistantMsg]);
355
+ service?.sendMessage(
356
+ userQuery,
357
+ {
358
+ onTextUpdate: (text) => {
359
+ const updatedMessages = [...chatMessages];
360
+ const lastMsg = updatedMessages[updatedMessages.length - 1];
361
+ if (lastMsg) {
362
+ lastMsg.content = text;
363
+ setChatMessages(updatedMessages);
364
+ }
365
+ },
366
+ onProductSkus: (skus) => {
367
+ const updatedMessages = [...chatMessages];
368
+ const lastMsg = updatedMessages[updatedMessages.length - 1];
369
+ if (lastMsg) {
370
+ lastMsg.productSkus = skus;
371
+ setChatMessages(updatedMessages);
372
+ }
373
+ },
374
+ onLoadingChange: (loading) => {
375
+ setIsLoading(loading);
376
+ },
377
+ onError: (err) => {
378
+ setError(err);
379
+ },
380
+ onCartOperation: (ops) => {
381
+ if (props.onCartOperation) {
382
+ props.onCartOperation(ops);
383
+ }
384
+ },
385
+ },
386
+ props.cart || []
387
+ );
388
+ }
389
+
390
+ function toggleChat() {
391
+ setShowChat(!showChat);
392
+ if (!showChat && props.onClose) {
393
+ props.onClose();
394
+ }
395
+ }
396
+
397
+ function handleNewChat() {
398
+ setChatMessages([]);
399
+ service?.resetSession();
400
+ }
401
+
402
+ function onPopularItemsClick() {
403
+ setInput(TRANSLATIONS.showPopularItems);
404
+ handleSend();
405
+ }
406
+
407
+ function onCompareProductsClick() {
408
+ setInput(TRANSLATIONS.compareProducts);
409
+ handleSend();
410
+ }
411
+
412
+ function onInputChange(event) {
413
+ setInput(event.target.value);
414
+ }
415
+
416
+ function onInputKeyDown(event) {
417
+ if (event.key === "Enter") {
418
+ handleSend();
419
+ }
420
+ }
421
+
422
+ function onHeaderButtonMouseEnter() {
423
+ setIsHeaderButtonHovered(true);
424
+ }
425
+
426
+ function onHeaderButtonMouseLeave() {
427
+ setIsHeaderButtonHovered(false);
428
+ }
429
+
430
+ function doSomethingAsync() {
431
+ void (async function () {
432
+ console.log("## ~ ShopPrompter ~ state.service:", service);
433
+ if (!service) {
434
+ console.warn("Service not initialized yet");
435
+ return;
436
+ }
437
+ const response = await service?.getAgentExperience();
438
+ console.log("## ~ ShopPrompter ~ response:", response);
439
+ setAgentExperience(response);
440
+ })();
441
+ }
442
+
443
+ useEffect(() => {
444
+ const shopPrompterService = new ShopPrompterService();
445
+ setService(shopPrompterService);
446
+ }, []);
447
+ useEffect(() => {
448
+ if (service && !agentExperience) {
449
+ doSomethingAsync();
450
+ }
451
+ if (agentExperience) {
452
+ console.log("## ~ ShopPrompter ~ agentExperience updated:", {
453
+ greeting: agentExperience.greeting,
454
+ agentLogoUrl: agentExperience.agentLogoUrl,
455
+ });
456
+ }
457
+ }, [service, agentExperience]);
458
+
459
+ return (
460
+ <div className="shopprompter-sdk">
461
+ {props.chatPosition === "classic-chatbot" ? (
462
+ <>
463
+ {!showChat ? (
464
+ <button
465
+ className="fixed bottom-6 right-6 w-16 h-16 bg-blue-600 hover:bg-blue-700 rounded-full shadow-lg z-50 flex items-center justify-center transition-colors border-none cursor-pointer"
466
+ onClick={(e) => toggleChat()}
467
+ style={{
468
+ boxShadow: "0 0 0 8px rgba(37, 99, 235, 0.2)",
469
+ }}
470
+ >
471
+ <img
472
+ alt="Chat"
473
+ src={ICONS.chat}
474
+ style={{
475
+ width: "28px",
476
+ height: "28px",
477
+ }}
478
+ />
479
+ </button>
480
+ ) : null}
481
+ </>
482
+ ) : null}
483
+ {showChat ? (
484
+ <div style={containerStyle()} className={containerClass()}>
485
+ <div style={styles.header}>
486
+ <div style={styles.subHeaderContainer}>
487
+ <svg
488
+ xmlns="http://www.w3.org/2000/svg"
489
+ viewBox="0 0 46 47"
490
+ width="24"
491
+ height="24"
492
+ fill="none"
493
+ >
494
+ <path
495
+ fill="url(#a)"
496
+ d="M16.452 32.747c-1.587 0-2.874-1.3-2.874-2.903V14.25h5.259V0H5.747C2.576 0 0 2.6 0 5.806v21.139c0 3.208 2.575 5.805 5.748 5.805h10.704v-.003Z"
497
+ />
498
+ <path
499
+ fill="url(#b)"
500
+ d="M19.326 0c-3.173 0-5.748 2.6-5.748 5.806v8.444h15.438c1.586 0 2.874 1.3 2.874 2.902v3.924H46V0H19.326Z"
501
+ />
502
+ <path
503
+ fill="url(#c)"
504
+ d="M40.252 14.25H29.016c1.586 0 2.874 1.3 2.874 2.902v15.595h-6.751V47h15.117c3.173 0 5.748-2.6 5.748-5.806V20.055c0-3.205-2.575-5.806-5.748-5.806h-.004Z"
505
+ />
506
+ <path
507
+ fill="url(#d)"
508
+ d="M8.669 32.75H5.751c-3.173 0-5.747-2.6-5.747-5.805V47h26.142c3.172 0 5.747-2.6 5.747-5.806V32.75H8.67Z"
509
+ />
510
+ <defs>
511
+ <linearGradient
512
+ id="a"
513
+ x1="14.3"
514
+ x2="3.322"
515
+ y1="22.494"
516
+ y2="4.382"
517
+ gradientUnits="userSpaceOnUse"
518
+ >
519
+ <stop stopColor="#B0145C" />
520
+ <stop offset=".37" stopColor="#AE2E9A" />
521
+ <stop offset="1" stopColor="#AD59FF" />
522
+ </linearGradient>
523
+ <linearGradient
524
+ id="b"
525
+ x1="21.156"
526
+ x2="40.431"
527
+ y1="21.216"
528
+ y2="1.624"
529
+ gradientUnits="userSpaceOnUse"
530
+ >
531
+ <stop offset=".08" stopColor="#E7A2FF" />
532
+ <stop offset=".37" stopColor="#E983CD" />
533
+ <stop offset=".99" stopColor="#F03A58" />
534
+ </linearGradient>
535
+ <linearGradient
536
+ id="c"
537
+ x1="30.464"
538
+ x2="46.567"
539
+ y1="27.405"
540
+ y2="42.472"
541
+ gradientUnits="userSpaceOnUse"
542
+ >
543
+ <stop stopColor="#B0145C" />
544
+ <stop offset=".02" stopColor="#B11861" />
545
+ <stop offset=".27" stopColor="#C44999" />
546
+ <stop offset=".5" stopColor="#D36FC5" />
547
+ <stop offset=".71" stopColor="#DE8BE4" />
548
+ <stop offset=".88" stopColor="#E49BF8" />
549
+ <stop offset="1" stopColor="#E7A2FF" />
550
+ </linearGradient>
551
+ <linearGradient
552
+ id="d"
553
+ x1="23.356"
554
+ x2="-.618"
555
+ y1="44.082"
556
+ y2="30.739"
557
+ gradientUnits="userSpaceOnUse"
558
+ >
559
+ <stop stopColor="#AD59FF" />
560
+ <stop offset=".1" stopColor="#B455EB" />
561
+ <stop offset=".54" stopColor="#D4469C" />
562
+ <stop offset=".85" stopColor="#E83D6B" />
563
+ <stop offset="1" stopColor="#F03A58" />
564
+ </linearGradient>
565
+ </defs>
566
+ </svg>
567
+ <span style={styles.headerText}>ShopPrompter&reg;</span>
568
+ </div>
569
+ <div style={styles.subHeaderContainer}>
570
+ <button
571
+ onClick={(e) => handleNewChat()}
572
+ onMouseEnter={(e) => onHeaderButtonMouseEnter()}
573
+ onMouseLeave={(e) => onHeaderButtonMouseLeave()}
574
+ style={{
575
+ ...styles.headerButton,
576
+ ...(isHeaderButtonHovered ? styles.headerButton.onHover : {}),
577
+ }}
578
+ >
579
+ {TRANSLATIONS.newChat}
580
+ </button>
581
+ {props.chatPosition === "classic-chatbot" ||
582
+ props.chatPosition === "right-panel" ||
583
+ props.chatPosition === "bottom-sheet" ? (
584
+ <button
585
+ onClick={(e) => toggleChat()}
586
+ style={styles.ButtonSheetButton}
587
+ >
588
+ &times;
589
+ </button>
590
+ ) : null}
591
+ </div>
592
+ </div>
593
+ <div style={styles.chatContainer}>
594
+ {showWelcome() ? (
595
+ <div style={styles.welcomeContainer}>
596
+ <img
597
+ alt="ShopPrompter"
598
+ src={
599
+ agentExperience?.agentLogoUrl
600
+ ? agentExperience.agentLogoUrl
601
+ : ICONS.shopprompter
602
+ }
603
+ style={{
604
+ width: "64px",
605
+ height: "64px",
606
+ marginBottom: "24px",
607
+ }}
608
+ />
609
+ <h3 style={styles.welcomeTitle}>
610
+ {agentExperience?.greeting?.title ||
611
+ TRANSLATIONS.welcomeToShopPrompter}
612
+ </h3>
613
+ <p style={styles.welcomeDescription}>
614
+ {agentExperience?.greeting?.description ||
615
+ TRANSLATIONS.welcomeDescription}
616
+ </p>
617
+ <div style={styles.buttonContainer}>
618
+ <button
619
+ style={styles.button}
620
+ onClick={(e) => onPopularItemsClick()}
621
+ >
622
+ {TRANSLATIONS.showPopularItems}
623
+ </button>
624
+ <button
625
+ style={styles.button}
626
+ onClick={(e) => onCompareProductsClick()}
627
+ >
628
+ {TRANSLATIONS.compareProducts}
629
+ </button>
630
+ </div>
631
+ </div>
632
+ ) : (
633
+ <>
634
+ {messages()?.map((message) => (
635
+ <div
636
+ key={message.id}
637
+ style={
638
+ message.role === "user"
639
+ ? styles.messageContainerUser
640
+ : styles.messageContainerAssistant
641
+ }
642
+ >
643
+ <div
644
+ style={
645
+ message.role === "user"
646
+ ? styles.messageBubbleUser
647
+ : styles.messageBubbleAssistant
648
+ }
649
+ >
650
+ {message.content}
651
+ {!message.content ? (
652
+ <>
653
+ {message.role === "assistant" ? (
654
+ <>
655
+ {isLoading ? (
656
+ <div style={styles.thinkingIndicator}>
657
+ {TRANSLATIONS.thinking}
658
+ </div>
659
+ ) : null}
660
+ </>
661
+ ) : null}
662
+ </>
663
+ ) : null}
664
+ </div>
665
+ {message.role === "assistant" ? (
666
+ <div style={styles.productCardsContainer}>
667
+ {message.safeProductSkus?.map((sku) => (
668
+ <div key={sku} style={styles.productCard}>
669
+ <div style={styles.productImageContainer}>
670
+ <img
671
+ src={getProductImageUrl(sku)}
672
+ alt={sku}
673
+ style={{
674
+ maxHeight: "100%",
675
+ maxWidth: "100%",
676
+ }}
677
+ />
678
+ </div>
679
+ <div style={styles.productInfo}>
680
+ <p style={styles.productSku}>{sku}</p>
681
+ <a
682
+ href={getProductLink(sku)}
683
+ style={styles.productLink}
684
+ >
685
+ VIEW DETAILS
686
+ </a>
687
+ </div>
688
+ </div>
689
+ ))}
690
+ </div>
691
+ ) : null}
692
+ </div>
693
+ ))}
694
+ </>
695
+ )}
696
+ {error ? (
697
+ <div style={styles.errorContainer}>Error: {error}</div>
698
+ ) : null}
699
+ </div>
700
+ <div style={styles.inputSection}>
701
+ <div style={styles.inputWrapper}>
702
+ <input
703
+ type="text"
704
+ style={styles.input}
705
+ placeholder={TRANSLATIONS.askMeAnything}
706
+ value={input}
707
+ onInput={(e) => onInputChange(e)}
708
+ onKeyDown={(e) => onInputKeyDown(e)}
709
+ />
710
+ <button
711
+ onClick={(e) => handleSend()}
712
+ style={{
713
+ ...styles.formButton,
714
+ ...styles.sendButton,
715
+ }}
716
+ >
717
+ <img alt="Send" src={ICONS.sendHorizontal} />
718
+ </button>
719
+ </div>
720
+ <p style={styles.disclaimer}>AI content may be inaccurate.</p>
721
+ </div>
722
+ </div>
723
+ ) : null}
724
+ </div>
725
+ );
726
+ }
727
+
728
+ export default ShopPrompter;