vpschatbotwidget 1.0.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/Chatbot.svg +1 -0
- package/README.md +86 -0
- package/dist/assets/index-C0fUDi2s.css +1 -0
- package/dist/assets/index-foGq5_Av.js +159 -0
- package/dist/index.html +17 -0
- package/index.html +16 -0
- package/package.json +47 -0
- package/src/App.tsx +85 -0
- package/src/chatbot/api/chatbot-api.ts +258 -0
- package/src/chatbot/api/chatbot-types.ts +145 -0
- package/src/chatbot/chatbot.test.tsx +274 -0
- package/src/chatbot/config/colors.ts +166 -0
- package/src/chatbot/config/suggestions.ts +21 -0
- package/src/chatbot/core/ChatContext.tsx +43 -0
- package/src/chatbot/core/ChatEmptyState.tsx +21 -0
- package/src/chatbot/core/ChatError.tsx +26 -0
- package/src/chatbot/core/ChatHeader.tsx +108 -0
- package/src/chatbot/core/ChatInput.tsx +103 -0
- package/src/chatbot/core/ChatMarkdown.tsx +87 -0
- package/src/chatbot/core/ChatMessage.tsx +115 -0
- package/src/chatbot/core/ChatMessageList.tsx +47 -0
- package/src/chatbot/core/ChatPanel.tsx +66 -0
- package/src/chatbot/core/ChatProvider.tsx +185 -0
- package/src/chatbot/core/ChatSuggestions.tsx +71 -0
- package/src/chatbot/core/ChatTicketConfirmation.tsx +59 -0
- package/src/chatbot/core/ChatTypingIndicator.tsx +16 -0
- package/src/chatbot/core/ticket-intent.ts +12 -0
- package/src/chatbot/embedded/EmbeddedChatbot.tsx +47 -0
- package/src/chatbot/embedded/EmbeddedChatbotPanel.tsx +56 -0
- package/src/chatbot/embedded/EmbeddedChatbotTrigger.tsx +167 -0
- package/src/chatbot/hooks/useChatbot.ts +5 -0
- package/src/chatbot/index.ts +7 -0
- package/src/chatbot/widget/ChatbotWidget.tsx +43 -0
- package/src/chatbot/widget/ChatbotWidgetPanel.tsx +39 -0
- package/src/chatbot/widget/ChatbotWidgetTrigger.tsx +32 -0
- package/src/components/AgentSummaryCard.tsx +37 -0
- package/src/components/ChatHeader.tsx +142 -0
- package/src/components/ChatInput.tsx +123 -0
- package/src/components/ChatWidget.tsx +295 -0
- package/src/components/ConnectingStatus.tsx +16 -0
- package/src/components/EnvBadge.tsx +103 -0
- package/src/components/FeedbackRatingCard.tsx +123 -0
- package/src/components/MessageItem.tsx +157 -0
- package/src/components/MessageList.tsx +143 -0
- package/src/components/OrderTrackingCard.tsx +104 -0
- package/src/components/QuickPrompts.tsx +46 -0
- package/src/components/ResponseIconMapper.tsx +155 -0
- package/src/components/SourceCitations.tsx +46 -0
- package/src/components/ToolCallBadge.tsx +29 -0
- package/src/components/TypingProgressBar.tsx +113 -0
- package/src/components/ui/message-scroller.tsx +128 -0
- package/src/index.css +550 -0
- package/src/lib/cn.ts +5 -0
- package/src/lib/gibberishDetector.ts +159 -0
- package/src/lib/textHighlighter.tsx +206 -0
- package/src/main.tsx +10 -0
- package/src/services/api.ts +74 -0
- package/src/test/message-scroller-stub.tsx +60 -0
- package/src/test/setup.ts +8 -0
- package/src/types/chat.ts +66 -0
- package/src/vite-env.d.ts +14 -0
- package/tsconfig.json +21 -0
- package/vite.config.ts +28 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { useState, useRef } from "react";
|
|
2
|
+
import { Smile, Paperclip, AlertTriangle } from "lucide-react";
|
|
3
|
+
import { detectGibberish } from "../lib/gibberishDetector";
|
|
4
|
+
|
|
5
|
+
interface ChatInputProps {
|
|
6
|
+
onSendMessage: (message: string) => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
poweredByText?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Default message shown when gibberish is detected */
|
|
13
|
+
const GIBBERISH_WARNING =
|
|
14
|
+
"It looks like that might not be a readable message. Please type a clear question or request so I can help you properly. 😊";
|
|
15
|
+
|
|
16
|
+
export const ChatInput: React.FC<ChatInputProps> = ({
|
|
17
|
+
onSendMessage,
|
|
18
|
+
disabled = false,
|
|
19
|
+
placeholder = "Type message",
|
|
20
|
+
poweredByText = "Powered by kirridesk",
|
|
21
|
+
}) => {
|
|
22
|
+
const [text, setText] = useState("");
|
|
23
|
+
const [warning, setWarning] = useState<string | null>(null);
|
|
24
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
25
|
+
|
|
26
|
+
const handleSend = () => {
|
|
27
|
+
if (!text.trim() || disabled) return;
|
|
28
|
+
|
|
29
|
+
const { isGibberish, reason } = detectGibberish(text.trim());
|
|
30
|
+
|
|
31
|
+
if (isGibberish) {
|
|
32
|
+
// Show inline warning — do NOT call onSendMessage (saves AI tokens)
|
|
33
|
+
setWarning(GIBBERISH_WARNING);
|
|
34
|
+
console.info("[ChatInput] Gibberish blocked:", reason);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setWarning(null);
|
|
39
|
+
onSendMessage(text.trim());
|
|
40
|
+
setText("");
|
|
41
|
+
if (textareaRef.current) {
|
|
42
|
+
textareaRef.current.style.height = "auto";
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
47
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
handleSend();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
54
|
+
setText(e.target.value);
|
|
55
|
+
// Clear warning as soon as the user starts editing
|
|
56
|
+
if (warning) setWarning(null);
|
|
57
|
+
e.target.style.height = "auto";
|
|
58
|
+
e.target.style.height = `${Math.min(e.target.scrollHeight, 100)}px`;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className="chat-input-wrapper">
|
|
63
|
+
{/* Gibberish / unreadable input warning banner */}
|
|
64
|
+
{warning && (
|
|
65
|
+
<div className="chat-input-warning" role="alert" aria-live="polite">
|
|
66
|
+
<AlertTriangle size={14} className="chat-input-warning-icon" />
|
|
67
|
+
<span>{warning}</span>
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
<div className="chat-input-box">
|
|
72
|
+
{/* Emoji trigger */}
|
|
73
|
+
<button
|
|
74
|
+
type="button"
|
|
75
|
+
className="input-icon-btn"
|
|
76
|
+
title="Insert emoji"
|
|
77
|
+
aria-label="Emoji"
|
|
78
|
+
>
|
|
79
|
+
<Smile size={18} />
|
|
80
|
+
</button>
|
|
81
|
+
|
|
82
|
+
{/* Attachment trigger */}
|
|
83
|
+
<button
|
|
84
|
+
type="button"
|
|
85
|
+
className="input-icon-btn"
|
|
86
|
+
title="Attach file"
|
|
87
|
+
aria-label="Attach file"
|
|
88
|
+
>
|
|
89
|
+
<Paperclip size={18} />
|
|
90
|
+
</button>
|
|
91
|
+
|
|
92
|
+
{/* Text Input */}
|
|
93
|
+
<textarea
|
|
94
|
+
ref={textareaRef}
|
|
95
|
+
className={`chat-textarea${warning ? " chat-textarea--warn" : ""}`}
|
|
96
|
+
value={text}
|
|
97
|
+
onChange={handleInput}
|
|
98
|
+
onKeyDown={handleKeyDown}
|
|
99
|
+
placeholder={placeholder}
|
|
100
|
+
disabled={disabled}
|
|
101
|
+
rows={1}
|
|
102
|
+
aria-label="Chat message input"
|
|
103
|
+
/>
|
|
104
|
+
|
|
105
|
+
{/* Send Button */}
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
className="chat-send-btn"
|
|
109
|
+
onClick={handleSend}
|
|
110
|
+
disabled={disabled || !text.trim()}
|
|
111
|
+
title="Send message (Enter)"
|
|
112
|
+
>
|
|
113
|
+
Send
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
{/* Footer Branding */}
|
|
118
|
+
<div className="chat-powered-by">
|
|
119
|
+
<span>{poweredByText}</span>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { Message } from "../types/chat";
|
|
3
|
+
import { ChatService } from "../services/api";
|
|
4
|
+
import { ChatHeader, HeaderMode } from "./ChatHeader";
|
|
5
|
+
import { MessageList } from "./MessageList";
|
|
6
|
+
import { ChatInput } from "./ChatInput";
|
|
7
|
+
import { OrderTrackingCard } from "./OrderTrackingCard";
|
|
8
|
+
import { QuickOption } from "./QuickPrompts";
|
|
9
|
+
import { type EnvStage } from "./EnvBadge";
|
|
10
|
+
|
|
11
|
+
export type WidgetViewPreset = "bot" | "agent" | "ended" | "live";
|
|
12
|
+
|
|
13
|
+
interface ChatWidgetProps {
|
|
14
|
+
mode?: "floating" | "embedded";
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
preset?: WidgetViewPreset;
|
|
17
|
+
/** Environment badge stage shown in the header. Omit for production. */
|
|
18
|
+
envStage?: EnvStage;
|
|
19
|
+
/** Whether the dot inside the badge pulses. Default: true */
|
|
20
|
+
envPulse?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const MOCK_BOT_MESSAGES: Message[] = [
|
|
24
|
+
{
|
|
25
|
+
id: "bot-1",
|
|
26
|
+
role: "assistant",
|
|
27
|
+
content:
|
|
28
|
+
"Hey ! i'm a Hazell Chat Bot ! Ask me anything or share your feedback or selectan option below.",
|
|
29
|
+
timestamp: new Date().toISOString(),
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "user-1",
|
|
33
|
+
role: "user",
|
|
34
|
+
content: "Chat With the sales team",
|
|
35
|
+
timestamp: new Date().toISOString(),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "bot-2",
|
|
39
|
+
role: "assistant",
|
|
40
|
+
content: "Got you, please wait to connecting with agent in kirridesk.",
|
|
41
|
+
timestamp: new Date().toISOString(),
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const MOCK_AGENT_MESSAGES: Message[] = [
|
|
46
|
+
{
|
|
47
|
+
id: "agent-1",
|
|
48
|
+
role: "assistant",
|
|
49
|
+
content:
|
|
50
|
+
"I'm sorry to hear that. Have you checked the tracking information for your package?",
|
|
51
|
+
timestamp: new Date().toISOString(),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "user-1",
|
|
55
|
+
role: "user",
|
|
56
|
+
content: "Yes, I did, but it says it's still in transit for several days.",
|
|
57
|
+
timestamp: new Date().toISOString(),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "agent-2",
|
|
61
|
+
role: "assistant",
|
|
62
|
+
content: "In that case, can you give me your order ID?",
|
|
63
|
+
timestamp: new Date().toISOString(),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "user-2",
|
|
67
|
+
role: "user",
|
|
68
|
+
content: "Alright, SO-567",
|
|
69
|
+
timestamp: new Date().toISOString(),
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const MOCK_ENDED_MESSAGES: Message[] = [
|
|
74
|
+
{
|
|
75
|
+
id: "agent-1",
|
|
76
|
+
role: "assistant",
|
|
77
|
+
content:
|
|
78
|
+
"You're welcome! I hope your package arrives soon. Let me know if there's anything else I can assist you with.",
|
|
79
|
+
timestamp: new Date().toISOString(),
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const DEFAULT_QUICK_OPTIONS: QuickOption[] = [
|
|
84
|
+
{ label: "Get free training", query: "Get free training" },
|
|
85
|
+
{ label: "Get Started free", query: "Get Started free" },
|
|
86
|
+
{ label: "Chat with the sales team", query: "Chat with the sales team" },
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
export const ChatWidget: React.FC<ChatWidgetProps> = ({
|
|
90
|
+
mode = "embedded",
|
|
91
|
+
onClose,
|
|
92
|
+
preset = "live",
|
|
93
|
+
envStage,
|
|
94
|
+
envPulse = true,
|
|
95
|
+
}) => {
|
|
96
|
+
const [sessionId, setSessionId] = useState<string | null>(null);
|
|
97
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
98
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
99
|
+
const [isConnectingAgent, setIsConnectingAgent] = useState(false);
|
|
100
|
+
|
|
101
|
+
// Determine current display states based on preset or dynamic conversation
|
|
102
|
+
const isPresetBot = preset === "bot";
|
|
103
|
+
const isPresetAgent = preset === "agent";
|
|
104
|
+
const isPresetEnded = preset === "ended";
|
|
105
|
+
|
|
106
|
+
const headerMode: HeaderMode = isPresetBot
|
|
107
|
+
? "bot"
|
|
108
|
+
: isPresetEnded
|
|
109
|
+
? "ended"
|
|
110
|
+
: isPresetAgent
|
|
111
|
+
? "agent"
|
|
112
|
+
: "bot";
|
|
113
|
+
|
|
114
|
+
const showTrackingCard = isPresetAgent;
|
|
115
|
+
const isChatClosed = isPresetEnded;
|
|
116
|
+
const showFeedbackCard = isPresetEnded;
|
|
117
|
+
|
|
118
|
+
// Initialize or resume chat session for live mode
|
|
119
|
+
const initSession = async (reset = false) => {
|
|
120
|
+
if (preset !== "live") {
|
|
121
|
+
if (isPresetBot) {
|
|
122
|
+
setMessages(MOCK_BOT_MESSAGES);
|
|
123
|
+
setIsConnectingAgent(true);
|
|
124
|
+
} else if (isPresetAgent) {
|
|
125
|
+
setMessages(MOCK_AGENT_MESSAGES);
|
|
126
|
+
setIsConnectingAgent(false);
|
|
127
|
+
} else if (isPresetEnded) {
|
|
128
|
+
setMessages(MOCK_ENDED_MESSAGES);
|
|
129
|
+
setIsConnectingAgent(false);
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
setIsLoading(true);
|
|
136
|
+
if (sessionId && reset) {
|
|
137
|
+
await ChatService.closeSession(sessionId);
|
|
138
|
+
}
|
|
139
|
+
const newId = await ChatService.createSession();
|
|
140
|
+
setSessionId(newId);
|
|
141
|
+
setMessages([]);
|
|
142
|
+
setIsConnectingAgent(false);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.error("Failed to initialize session:", err);
|
|
145
|
+
} finally {
|
|
146
|
+
setIsLoading(false);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
initSession();
|
|
152
|
+
}, [preset]);
|
|
153
|
+
|
|
154
|
+
const handleSendMessage = async (userMessage: string) => {
|
|
155
|
+
// If testing mock presets, append message locally
|
|
156
|
+
if (preset !== "live") {
|
|
157
|
+
const userMsgObj: Message = {
|
|
158
|
+
id: `user-${Date.now()}`,
|
|
159
|
+
role: "user",
|
|
160
|
+
content: userMessage,
|
|
161
|
+
timestamp: new Date().toISOString(),
|
|
162
|
+
};
|
|
163
|
+
setMessages((prev) => [...prev, userMsgObj]);
|
|
164
|
+
setIsLoading(true);
|
|
165
|
+
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
setIsLoading(false);
|
|
168
|
+
const replyMsgObj: Message = {
|
|
169
|
+
id: `asst-${Date.now()}`,
|
|
170
|
+
role: "assistant",
|
|
171
|
+
content: "Thank you for providing the details! I am checking on this for you right away.",
|
|
172
|
+
timestamp: new Date().toISOString(),
|
|
173
|
+
};
|
|
174
|
+
setMessages((prev) => [...prev, replyMsgObj]);
|
|
175
|
+
}, 1000);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let currentSession = sessionId;
|
|
180
|
+
if (!currentSession) {
|
|
181
|
+
try {
|
|
182
|
+
currentSession = await ChatService.createSession();
|
|
183
|
+
setSessionId(currentSession);
|
|
184
|
+
} catch {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const userMsgObj: Message = {
|
|
190
|
+
id: `user-${Date.now()}`,
|
|
191
|
+
role: "user",
|
|
192
|
+
content: userMessage,
|
|
193
|
+
timestamp: new Date().toISOString(),
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
setMessages((prev) => [...prev, userMsgObj]);
|
|
197
|
+
setIsLoading(true);
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
const response = await ChatService.sendMessage(currentSession, userMessage);
|
|
201
|
+
const assistantMsgObj: Message = {
|
|
202
|
+
id: response.request_id || `asst-${Date.now()}`,
|
|
203
|
+
role: "assistant",
|
|
204
|
+
content: response.answer,
|
|
205
|
+
timestamp: new Date().toISOString(),
|
|
206
|
+
sources: response.sources,
|
|
207
|
+
tool_calls: response.tool_calls,
|
|
208
|
+
usage: response.usage,
|
|
209
|
+
};
|
|
210
|
+
setMessages((prev) => [...prev, assistantMsgObj]);
|
|
211
|
+
} catch (err: any) {
|
|
212
|
+
const errorMsgObj: Message = {
|
|
213
|
+
id: `err-${Date.now()}`,
|
|
214
|
+
role: "assistant",
|
|
215
|
+
content: `⚠️ ${err.message || "An error occurred while connecting to the assistant."}`,
|
|
216
|
+
timestamp: new Date().toISOString(),
|
|
217
|
+
error: true,
|
|
218
|
+
};
|
|
219
|
+
setMessages((prev) => [...prev, errorMsgObj]);
|
|
220
|
+
} finally {
|
|
221
|
+
setIsLoading(false);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div className={`chat-card-container ${mode === "floating" ? "chat-card-floating" : "chat-card-embedded"}`}>
|
|
227
|
+
{/* Header */}
|
|
228
|
+
<ChatHeader
|
|
229
|
+
headerMode={headerMode}
|
|
230
|
+
ticketId="#TC-192"
|
|
231
|
+
subtitle="Help, I order wrong product"
|
|
232
|
+
duration="2:02"
|
|
233
|
+
agentInitials="FIK"
|
|
234
|
+
onReset={() => initSession(true)}
|
|
235
|
+
onClose={onClose}
|
|
236
|
+
isFloating={mode === "floating"}
|
|
237
|
+
envStage={envStage}
|
|
238
|
+
envPulse={envPulse}
|
|
239
|
+
/>
|
|
240
|
+
|
|
241
|
+
{/* Collapsible Order Tracking Stepper (Screen 2) */}
|
|
242
|
+
{showTrackingCard && (
|
|
243
|
+
<div style={{ padding: "12px 16px 0 16px" }}>
|
|
244
|
+
<OrderTrackingCard
|
|
245
|
+
orderId="#SO-567"
|
|
246
|
+
statusBadge="Paid"
|
|
247
|
+
totalAmount="$256.00"
|
|
248
|
+
steps={[
|
|
249
|
+
{ label: "Quoted", status: "completed" },
|
|
250
|
+
{ label: "Packed", status: "active" },
|
|
251
|
+
{ label: "Shipped", status: "pending" },
|
|
252
|
+
{ label: "Delivered", status: "pending" },
|
|
253
|
+
]}
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
)}
|
|
257
|
+
|
|
258
|
+
{/* Message Stream */}
|
|
259
|
+
<MessageList
|
|
260
|
+
messages={messages}
|
|
261
|
+
isLoading={isLoading}
|
|
262
|
+
isConnectingAgent={isConnectingAgent}
|
|
263
|
+
connectingLabel="Connecting with agent"
|
|
264
|
+
isChatClosed={isChatClosed}
|
|
265
|
+
showFeedbackCard={showFeedbackCard}
|
|
266
|
+
agentName="Fikri Studio"
|
|
267
|
+
agentInitials="FIK"
|
|
268
|
+
chatDuration="12 Mins 23 Sec"
|
|
269
|
+
isBot={isPresetBot || preset === "live"}
|
|
270
|
+
welcomeQuickOptions={DEFAULT_QUICK_OPTIONS}
|
|
271
|
+
onSelectPrompt={handleSendMessage}
|
|
272
|
+
onSubmitFeedback={(rating, reasons) => {
|
|
273
|
+
console.log("Feedback submitted:", { rating, reasons });
|
|
274
|
+
}}
|
|
275
|
+
/>
|
|
276
|
+
|
|
277
|
+
{/* Input Box (Active when chat is not closed) */}
|
|
278
|
+
{!isChatClosed && (
|
|
279
|
+
<ChatInput
|
|
280
|
+
onSendMessage={handleSendMessage}
|
|
281
|
+
disabled={isLoading}
|
|
282
|
+
placeholder="Type message"
|
|
283
|
+
poweredByText="Powered by kirridesk"
|
|
284
|
+
/>
|
|
285
|
+
)}
|
|
286
|
+
|
|
287
|
+
{/* Concluded footer when chat is ended */}
|
|
288
|
+
{isChatClosed && (
|
|
289
|
+
<div className="chat-powered-by" style={{ padding: "12px 0 16px 0" }}>
|
|
290
|
+
<span>Powered by kirridesk</span>
|
|
291
|
+
</div>
|
|
292
|
+
)}
|
|
293
|
+
</div>
|
|
294
|
+
);
|
|
295
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface ConnectingStatusProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const ConnectingStatus: React.FC<ConnectingStatusProps> = ({
|
|
8
|
+
label = "Connecting with agent",
|
|
9
|
+
}) => {
|
|
10
|
+
return (
|
|
11
|
+
<div className="connecting-status-container">
|
|
12
|
+
<div className="spinner-ring" />
|
|
13
|
+
<span className="connecting-status-text">{label}</span>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EnvBadge.tsx
|
|
3
|
+
*
|
|
4
|
+
* Renders a compact, animated environment stage badge.
|
|
5
|
+
*
|
|
6
|
+
* Supported stages
|
|
7
|
+
* ─────────────────
|
|
8
|
+
* "alpha" – earliest internal build (purple / FlaskConical)
|
|
9
|
+
* "beta" – public pre-release (blue / TestTubeDiagonal)
|
|
10
|
+
* "gamma" – release candidate (teal / Microscope)
|
|
11
|
+
* "qa" – quality assurance (amber / ClipboardCheck)
|
|
12
|
+
*
|
|
13
|
+
* Usage
|
|
14
|
+
* ──────
|
|
15
|
+
* <EnvBadge stage="beta" />
|
|
16
|
+
* <EnvBadge stage="alpha" pulse={false} />
|
|
17
|
+
*
|
|
18
|
+
* Returns null when `stage` is undefined → zero footprint in production.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import React from "react";
|
|
22
|
+
import {
|
|
23
|
+
FlaskConical,
|
|
24
|
+
TestTubeDiagonal,
|
|
25
|
+
Microscope,
|
|
26
|
+
ClipboardCheck,
|
|
27
|
+
} from "lucide-react";
|
|
28
|
+
|
|
29
|
+
// ── Public type (exported so parent props can reference it) ────────────────────
|
|
30
|
+
export type EnvStage = "alpha" | "beta" | "gamma" | "qa";
|
|
31
|
+
|
|
32
|
+
// ── Per-stage config ───────────────────────────────────────────────────────────
|
|
33
|
+
interface StageConfig {
|
|
34
|
+
label: string;
|
|
35
|
+
Icon: React.ElementType;
|
|
36
|
+
/** CSS modifier class on .env-badge */
|
|
37
|
+
variant: string;
|
|
38
|
+
tooltip: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const STAGE_CONFIG: Record<EnvStage, StageConfig> = {
|
|
42
|
+
alpha: {
|
|
43
|
+
label: "Alpha",
|
|
44
|
+
Icon: FlaskConical,
|
|
45
|
+
variant: "env-badge--alpha",
|
|
46
|
+
tooltip: "Alpha build — internal testing only",
|
|
47
|
+
},
|
|
48
|
+
beta: {
|
|
49
|
+
label: "Beta",
|
|
50
|
+
Icon: TestTubeDiagonal,
|
|
51
|
+
variant: "env-badge--beta",
|
|
52
|
+
tooltip: "Beta build — public pre-release",
|
|
53
|
+
},
|
|
54
|
+
gamma: {
|
|
55
|
+
label: "Gamma",
|
|
56
|
+
Icon: Microscope,
|
|
57
|
+
variant: "env-badge--gamma",
|
|
58
|
+
tooltip: "Gamma / Release Candidate",
|
|
59
|
+
},
|
|
60
|
+
qa: {
|
|
61
|
+
label: "QA",
|
|
62
|
+
Icon: ClipboardCheck,
|
|
63
|
+
variant: "env-badge--qa",
|
|
64
|
+
tooltip: "Quality Assurance build",
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// ── Props ──────────────────────────────────────────────────────────────────────
|
|
69
|
+
interface EnvBadgeProps {
|
|
70
|
+
/** Build stage to display. Omit entirely for production (renders nothing). */
|
|
71
|
+
stage?: EnvStage;
|
|
72
|
+
/** Whether the status dot pulses. Default: true */
|
|
73
|
+
pulse?: boolean;
|
|
74
|
+
/** Extra CSS class forwarded to the root element */
|
|
75
|
+
className?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ── Component ──────────────────────────────────────────────────────────────────
|
|
79
|
+
export const EnvBadge: React.FC<EnvBadgeProps> = ({
|
|
80
|
+
stage,
|
|
81
|
+
pulse = true,
|
|
82
|
+
className = "",
|
|
83
|
+
}) => {
|
|
84
|
+
if (!stage) return null;
|
|
85
|
+
|
|
86
|
+
const { label, Icon, variant, tooltip } = STAGE_CONFIG[stage];
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<span
|
|
90
|
+
className={`env-badge ${variant} ${className} text-[var(--vps-orange)] font-medium text-[10px] leading-[12px] px-1.5 py-0.5 rounded-full border border-[var(--border)] bg-[var(--orange-50)] hover:bg-[var(--grey-200)] cursor-pointer hover:text-foreground flex items-center gap-1 `}
|
|
91
|
+
title={tooltip}
|
|
92
|
+
aria-label={`${label} build`}
|
|
93
|
+
role="status"
|
|
94
|
+
>
|
|
95
|
+
|
|
96
|
+
{/* Icon */}
|
|
97
|
+
<Icon size={10} className="env-badge-icon" aria-hidden="true" />
|
|
98
|
+
|
|
99
|
+
{/* Label */}
|
|
100
|
+
<span className="text-[var(--text-primary)] font-medium text-[10px] leading-[12px]">{label}</span>
|
|
101
|
+
</span>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { ThumbsDown, ThumbsUp, Hand, CheckCircle2 } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
interface FeedbackRatingCardProps {
|
|
5
|
+
onSubmitFeedback?: (rating: string, reasons: string) => void;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type RatingType = "Bad" | "Okay" | "Good" | "Amazing";
|
|
10
|
+
|
|
11
|
+
export const FeedbackRatingCard: React.FC<FeedbackRatingCardProps> = ({
|
|
12
|
+
onSubmitFeedback,
|
|
13
|
+
onCancel,
|
|
14
|
+
}) => {
|
|
15
|
+
const [selectedRating, setSelectedRating] = useState<RatingType>("Amazing");
|
|
16
|
+
const [reasons, setReasons] = useState("");
|
|
17
|
+
const [isSubmitted, setIsSubmitted] = useState(false);
|
|
18
|
+
|
|
19
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
setIsSubmitted(true);
|
|
22
|
+
if (onSubmitFeedback) {
|
|
23
|
+
onSubmitFeedback(selectedRating, reasons);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (isSubmitted) {
|
|
28
|
+
return (
|
|
29
|
+
<div className="feedback-card feedback-submitted">
|
|
30
|
+
<CheckCircle2 size={36} color="#10B981" />
|
|
31
|
+
<h4>Thank you for your feedback!</h4>
|
|
32
|
+
<p>Your response helps us improve the support experience.</p>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className="feedback-card">
|
|
39
|
+
<h3 className="feedback-title">Thanks for the chat, How do you feel ?</h3>
|
|
40
|
+
|
|
41
|
+
<div className="rating-grid">
|
|
42
|
+
{/* Bad */}
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
className={`rating-item-btn ${selectedRating === "Bad" ? "rating-item-selected" : ""}`}
|
|
46
|
+
onClick={() => setSelectedRating("Bad")}
|
|
47
|
+
>
|
|
48
|
+
<div className="rating-icon-box">
|
|
49
|
+
<ThumbsDown size={22} />
|
|
50
|
+
</div>
|
|
51
|
+
<span className="rating-label">Bad</span>
|
|
52
|
+
</button>
|
|
53
|
+
|
|
54
|
+
{/* Okay */}
|
|
55
|
+
<button
|
|
56
|
+
type="button"
|
|
57
|
+
className={`rating-item-btn ${selectedRating === "Okay" ? "rating-item-selected" : ""}`}
|
|
58
|
+
onClick={() => setSelectedRating("Okay")}
|
|
59
|
+
>
|
|
60
|
+
<div className="rating-icon-box">
|
|
61
|
+
<span style={{ fontSize: "20px", lineHeight: "1" }}>✌️</span>
|
|
62
|
+
</div>
|
|
63
|
+
<span className="rating-label">Okay</span>
|
|
64
|
+
</button>
|
|
65
|
+
|
|
66
|
+
{/* Good */}
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
className={`rating-item-btn ${selectedRating === "Good" ? "rating-item-selected" : ""}`}
|
|
70
|
+
onClick={() => setSelectedRating("Good")}
|
|
71
|
+
>
|
|
72
|
+
<div className="rating-icon-box">
|
|
73
|
+
<Hand size={22} />
|
|
74
|
+
</div>
|
|
75
|
+
<span className="rating-label">Good</span>
|
|
76
|
+
</button>
|
|
77
|
+
|
|
78
|
+
{/* Amazing */}
|
|
79
|
+
<button
|
|
80
|
+
type="button"
|
|
81
|
+
className={`rating-item-btn ${selectedRating === "Amazing" ? "rating-item-selected" : ""}`}
|
|
82
|
+
onClick={() => setSelectedRating("Amazing")}
|
|
83
|
+
>
|
|
84
|
+
<div className="rating-icon-box">
|
|
85
|
+
<ThumbsUp size={22} />
|
|
86
|
+
</div>
|
|
87
|
+
<span className="rating-label">Amazing</span>
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div className="feedback-reasons-section">
|
|
92
|
+
<label className="feedback-reasons-label" htmlFor="rating-reasons">
|
|
93
|
+
What are the main reasons for your rating?
|
|
94
|
+
</label>
|
|
95
|
+
<textarea
|
|
96
|
+
id="rating-reasons"
|
|
97
|
+
className="feedback-textarea"
|
|
98
|
+
rows={3}
|
|
99
|
+
placeholder="Fill the reasons for you rating"
|
|
100
|
+
value={reasons}
|
|
101
|
+
onChange={(e) => setReasons(e.target.value)}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div className="feedback-actions">
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
className="feedback-btn-cancel"
|
|
109
|
+
onClick={onCancel}
|
|
110
|
+
>
|
|
111
|
+
Cancel
|
|
112
|
+
</button>
|
|
113
|
+
<button
|
|
114
|
+
type="button"
|
|
115
|
+
className="feedback-btn-submit"
|
|
116
|
+
onClick={handleSubmit}
|
|
117
|
+
>
|
|
118
|
+
Submit
|
|
119
|
+
</button>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
};
|