Create AIInsightCard.jsx
Browse files
frontend/src/components/admin/AIInsightCard.jsx
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// frontend/src/components/admin/AIInsightCard.jsx
|
| 2 |
+
import React from "react";
|
| 3 |
+
import { ArrowRight, TrendingUp, AlertTriangle, CheckCircle2, XCircle } from "lucide-react";
|
| 4 |
+
|
| 5 |
+
const typeStyles = {
|
| 6 |
+
growth: "bg-green-50 border-green-200",
|
| 7 |
+
warning: "bg-amber-50 border-amber-200",
|
| 8 |
+
success: "bg-blue-50 border-blue-200",
|
| 9 |
+
decline: "bg-red-50 border-red-200",
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
const typeIcons = {
|
| 13 |
+
growth: TrendingUp,
|
| 14 |
+
warning: AlertTriangle,
|
| 15 |
+
success: CheckCircle2,
|
| 16 |
+
decline: XCircle,
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
const typeIconColors = {
|
| 20 |
+
growth: "text-green-600",
|
| 21 |
+
warning: "text-amber-600",
|
| 22 |
+
success: "text-blue-600",
|
| 23 |
+
decline: "text-red-600",
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
const priorityBadges = {
|
| 27 |
+
high: "bg-red-100 text-red-700",
|
| 28 |
+
medium: "bg-amber-100 text-amber-700",
|
| 29 |
+
low: "bg-blue-100 text-blue-700",
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
export default function AIInsightCard({ insight }) {
|
| 33 |
+
const Icon = typeIcons[insight.type] || AlertTriangle;
|
| 34 |
+
|
| 35 |
+
return (
|
| 36 |
+
<div
|
| 37 |
+
className={`bg-white border rounded-xl p-4 shadow-sm ${typeStyles[insight.type] || "border-stone-200"}`}
|
| 38 |
+
>
|
| 39 |
+
<div className="flex items-start justify-between gap-2 mb-2">
|
| 40 |
+
<div className="flex items-center gap-2">
|
| 41 |
+
<Icon className={`w-5 h-5 ${typeIconColors[insight.type] || "text-stone-600"}`} />
|
| 42 |
+
<h3 className="font-semibold text-stone-900 text-sm">{insight.title}</h3>
|
| 43 |
+
</div>
|
| 44 |
+
<span
|
| 45 |
+
className={`text-xs px-2 py-0.5 rounded-full ${priorityBadges[insight.priority] || "bg-stone-100 text-stone-700"}`}
|
| 46 |
+
>
|
| 47 |
+
{insight.priority}
|
| 48 |
+
</span>
|
| 49 |
+
</div>
|
| 50 |
+
<p className="text-sm text-stone-700 mb-3">{insight.description}</p>
|
| 51 |
+
<div className="flex items-center justify-between">
|
| 52 |
+
{insight.metric && (
|
| 53 |
+
<div className="text-xs text-stone-600">
|
| 54 |
+
<span className="font-semibold text-stone-900">{insight.metric.value}</span>{" "}
|
| 55 |
+
{insight.metric.label}
|
| 56 |
+
</div>
|
| 57 |
+
)}
|
| 58 |
+
<button
|
| 59 |
+
type="button"
|
| 60 |
+
className="inline-flex items-center gap-1 text-xs font-medium text-purple-600 hover:text-purple-700"
|
| 61 |
+
>
|
| 62 |
+
{insight.actionLabel} <ArrowRight className="w-3 h-3" />
|
| 63 |
+
</button>
|
| 64 |
+
</div>
|
| 65 |
+
</div>
|
| 66 |
+
);
|
| 67 |
+
}
|
| 68 |
+
|