CognxSafeTrack commited on
Commit ·
2f133f7
1
Parent(s): 4339e77
feat: implement premium animated smart chips in CRM Dashboard chat UI
Browse files
apps/admin/src/components/crm/CrmAIAssistant.tsx
CHANGED
|
@@ -22,6 +22,14 @@ interface CrmAIAssistantProps {
|
|
| 22 |
onDrop: (e: React.DragEvent) => void;
|
| 23 |
onSendMessage: (e?: React.FormEvent) => void;
|
| 24 |
onValidateAndSend: (message: string) => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
export default function CrmAIAssistant({
|
|
@@ -36,7 +44,8 @@ export default function CrmAIAssistant({
|
|
| 36 |
onDragLeave,
|
| 37 |
onDrop,
|
| 38 |
onSendMessage,
|
| 39 |
-
onValidateAndSend
|
|
|
|
| 40 |
}: CrmAIAssistantProps) {
|
| 41 |
const messagesEndRef = useRef<HTMLDivElement>(null);
|
| 42 |
|
|
@@ -170,6 +179,31 @@ export default function CrmAIAssistant({
|
|
| 170 |
|
| 171 |
{/* Chat Input */}
|
| 172 |
<div className="p-8 bg-gradient-to-t from-slate-50 via-slate-50 to-transparent">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
<form
|
| 174 |
onSubmit={onSendMessage}
|
| 175 |
className="max-w-3xl mx-auto relative group"
|
|
|
|
| 22 |
onDrop: (e: React.DragEvent) => void;
|
| 23 |
onSendMessage: (e?: React.FormEvent) => void;
|
| 24 |
onValidateAndSend: (message: string) => void;
|
| 25 |
+
suggestions?: Array<{
|
| 26 |
+
id: string;
|
| 27 |
+
label: string;
|
| 28 |
+
prompt: string;
|
| 29 |
+
icon: any;
|
| 30 |
+
color: string;
|
| 31 |
+
bgColor: string;
|
| 32 |
+
}>;
|
| 33 |
}
|
| 34 |
|
| 35 |
export default function CrmAIAssistant({
|
|
|
|
| 44 |
onDragLeave,
|
| 45 |
onDrop,
|
| 46 |
onSendMessage,
|
| 47 |
+
onValidateAndSend,
|
| 48 |
+
suggestions = []
|
| 49 |
}: CrmAIAssistantProps) {
|
| 50 |
const messagesEndRef = useRef<HTMLDivElement>(null);
|
| 51 |
|
|
|
|
| 179 |
|
| 180 |
{/* Chat Input */}
|
| 181 |
<div className="p-8 bg-gradient-to-t from-slate-50 via-slate-50 to-transparent">
|
| 182 |
+
{/* Zone des Suggestions d'Actions (Premium UI) */}
|
| 183 |
+
{messages.length <= 3 && suggestions.length > 0 && (
|
| 184 |
+
<div className="max-w-3xl mx-auto mb-6 flex gap-3 overflow-x-auto pb-4 scrollbar-hide no-scrollbar">
|
| 185 |
+
{suggestions.map((action) => {
|
| 186 |
+
const Icon = action.icon;
|
| 187 |
+
return (
|
| 188 |
+
<motion.button
|
| 189 |
+
key={action.id}
|
| 190 |
+
whileHover={{ y: -2, scale: 1.02 }}
|
| 191 |
+
whileTap={{ scale: 0.98 }}
|
| 192 |
+
onClick={() => setInput(action.prompt)}
|
| 193 |
+
className="flex items-center gap-2 whitespace-nowrap px-4 py-2.5 bg-white border border-slate-200 shadow-sm rounded-xl hover:shadow-md hover:border-indigo-200 transition-all duration-200 group flex-shrink-0"
|
| 194 |
+
>
|
| 195 |
+
<div className={`p-1.5 rounded-lg ${action.bgColor} group-hover:scale-110 transition-transform`}>
|
| 196 |
+
<Icon className={`w-4 h-4 ${action.color}`} />
|
| 197 |
+
</div>
|
| 198 |
+
<span className="text-slate-700 text-sm font-medium">
|
| 199 |
+
{action.label}
|
| 200 |
+
</span>
|
| 201 |
+
</motion.button>
|
| 202 |
+
);
|
| 203 |
+
})}
|
| 204 |
+
</div>
|
| 205 |
+
)}
|
| 206 |
+
|
| 207 |
<form
|
| 208 |
onSubmit={onSendMessage}
|
| 209 |
className="max-w-3xl mx-auto relative group"
|
apps/admin/src/pages/CrmConversationalDashboard.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { useAuth } from '../lib/auth';
|
| 3 |
import { useTenant } from '../lib/tenant';
|
|
|
|
| 4 |
import CrmStatsHeader from '../components/crm/CrmStatsHeader';
|
| 5 |
import CrmAIAssistant from '../components/crm/CrmAIAssistant';
|
| 6 |
import CrmInbox from '../components/crm/CrmInbox';
|
|
@@ -12,6 +13,41 @@ interface Message {
|
|
| 12 |
timestamp: Date;
|
| 13 |
}
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
export default function CrmConversationalDashboard() {
|
| 16 |
const { token } = useAuth();
|
| 17 |
const { selectedOrgId } = useTenant();
|
|
@@ -250,6 +286,7 @@ export default function CrmConversationalDashboard() {
|
|
| 250 |
}}
|
| 251 |
onSendMessage={handleSendMessage}
|
| 252 |
onValidateAndSend={handleValidateAndSend}
|
|
|
|
| 253 |
/>
|
| 254 |
) : (
|
| 255 |
<CrmInbox
|
|
|
|
| 1 |
import { useState, useEffect } from 'react';
|
| 2 |
import { useAuth } from '../lib/auth';
|
| 3 |
import { useTenant } from '../lib/tenant';
|
| 4 |
+
import { Megaphone, Bot, FileSignature, BarChart3 } from 'lucide-react';
|
| 5 |
import CrmStatsHeader from '../components/crm/CrmStatsHeader';
|
| 6 |
import CrmAIAssistant from '../components/crm/CrmAIAssistant';
|
| 7 |
import CrmInbox from '../components/crm/CrmInbox';
|
|
|
|
| 13 |
timestamp: Date;
|
| 14 |
}
|
| 15 |
|
| 16 |
+
const SUGGESTED_ACTIONS = [
|
| 17 |
+
{
|
| 18 |
+
id: 'campaign',
|
| 19 |
+
label: "Nouvelle campagne",
|
| 20 |
+
prompt: "Rédige une campagne promotionnelle WhatsApp",
|
| 21 |
+
icon: Megaphone,
|
| 22 |
+
color: "text-blue-600",
|
| 23 |
+
bgColor: "bg-blue-50"
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
id: 'auto',
|
| 27 |
+
label: "Message auto",
|
| 28 |
+
prompt: "Configure un message d'absence automatique",
|
| 29 |
+
icon: Bot,
|
| 30 |
+
color: "text-emerald-600",
|
| 31 |
+
bgColor: "bg-emerald-50"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
id: 'template',
|
| 35 |
+
label: "Créer un Modèle",
|
| 36 |
+
prompt: "Aide-moi à créer un template validé par Meta",
|
| 37 |
+
icon: FileSignature,
|
| 38 |
+
color: "text-purple-600",
|
| 39 |
+
bgColor: "bg-purple-50"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
id: 'stats',
|
| 43 |
+
label: "Analyser",
|
| 44 |
+
prompt: "Fais-moi un résumé analytique des dernières réponses",
|
| 45 |
+
icon: BarChart3,
|
| 46 |
+
color: "text-orange-600",
|
| 47 |
+
bgColor: "bg-orange-50"
|
| 48 |
+
}
|
| 49 |
+
];
|
| 50 |
+
|
| 51 |
export default function CrmConversationalDashboard() {
|
| 52 |
const { token } = useAuth();
|
| 53 |
const { selectedOrgId } = useTenant();
|
|
|
|
| 286 |
}}
|
| 287 |
onSendMessage={handleSendMessage}
|
| 288 |
onValidateAndSend={handleValidateAndSend}
|
| 289 |
+
suggestions={SUGGESTED_ACTIONS}
|
| 290 |
/>
|
| 291 |
) : (
|
| 292 |
<CrmInbox
|