Update frontend/src/components/admin/AIInsightBox.jsx
Browse files
frontend/src/components/admin/AIInsightBox.jsx
CHANGED
|
@@ -11,9 +11,10 @@ import { differenceInDays } from "date-fns";
|
|
| 11 |
|
| 12 |
export default function AIInsightBox({
|
| 13 |
memberships = [],
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
}) {
|
| 18 |
const now = new Date();
|
| 19 |
|
|
@@ -31,7 +32,9 @@ export default function AIInsightBox({
|
|
| 31 |
return m.status === "expired" || days < 0;
|
| 32 |
}).length;
|
| 33 |
|
| 34 |
-
const goodStanding = memberships.filter(
|
|
|
|
|
|
|
| 35 |
|
| 36 |
const suggestionText =
|
| 37 |
totalMembers === 0
|
|
@@ -40,12 +43,6 @@ export default function AIInsightBox({
|
|
| 40 |
needAttention === 1 ? "" : "s"
|
| 41 |
} this week to improve retention.`;
|
| 42 |
|
| 43 |
-
const clickableRowBase =
|
| 44 |
-
"flex items-center justify-between rounded-2xl bg-white/90 px-4 py-3 shadow-sm transition hover:shadow-md cursor-pointer";
|
| 45 |
-
|
| 46 |
-
const staticRowBase =
|
| 47 |
-
"flex items-center justify-between rounded-2xl bg-white/90 px-4 py-3 shadow-sm";
|
| 48 |
-
|
| 49 |
return (
|
| 50 |
<div className="mb-8 rounded-3xl border border-purple-200 bg-gradient-to-r from-purple-50 to-purple-100/70 px-4 py-5 sm:px-6 sm:py-6">
|
| 51 |
<h2 className="text-sm font-semibold text-stone-900 mb-4 flex items-center gap-2">
|
|
@@ -56,26 +53,28 @@ export default function AIInsightBox({
|
|
| 56 |
</h2>
|
| 57 |
|
| 58 |
<div className="space-y-3">
|
| 59 |
-
{/* Row 1
|
| 60 |
-
<
|
| 61 |
-
|
| 62 |
-
onClick={
|
|
|
|
| 63 |
>
|
| 64 |
<div className="flex items-center gap-3">
|
| 65 |
<div className="h-8 w-8 rounded-full bg-emerald-50 flex items-center justify-center">
|
| 66 |
<TrendingUp className="w-4 h-4 text-emerald-600" />
|
| 67 |
</div>
|
| 68 |
<p className="text-sm text-stone-700">
|
| 69 |
-
{renewingSoon} member{renewingSoon === 1 ? "" : "s"} are
|
| 70 |
-
renewal in the next 2 weeks
|
| 71 |
</p>
|
| 72 |
</div>
|
| 73 |
-
</
|
| 74 |
|
| 75 |
-
{/* Row 2
|
| 76 |
-
<
|
| 77 |
-
|
| 78 |
-
onClick={
|
|
|
|
| 79 |
>
|
| 80 |
<div className="flex items-center gap-3">
|
| 81 |
<div className="h-8 w-8 rounded-full bg-amber-50 flex items-center justify-center">
|
|
@@ -86,12 +85,13 @@ export default function AIInsightBox({
|
|
| 86 |
immediate attention for renewal
|
| 87 |
</p>
|
| 88 |
</div>
|
| 89 |
-
</
|
| 90 |
|
| 91 |
-
{/* Row 3
|
| 92 |
-
<
|
| 93 |
-
|
| 94 |
-
onClick={
|
|
|
|
| 95 |
>
|
| 96 |
<div className="flex items-center gap-3">
|
| 97 |
<div className="h-8 w-8 rounded-full bg-blue-50 flex items-center justify-center">
|
|
@@ -102,19 +102,21 @@ export default function AIInsightBox({
|
|
| 102 |
maintaining good standing
|
| 103 |
</p>
|
| 104 |
</div>
|
| 105 |
-
</
|
| 106 |
|
| 107 |
{/* Suggestion row */}
|
| 108 |
-
<
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
| 116 |
</p>
|
| 117 |
-
</
|
| 118 |
</div>
|
| 119 |
</div>
|
| 120 |
);
|
|
|
|
| 11 |
|
| 12 |
export default function AIInsightBox({
|
| 13 |
memberships = [],
|
| 14 |
+
onRenewingSoonClick,
|
| 15 |
+
onNeedAttentionClick,
|
| 16 |
+
onGoodStandingClick,
|
| 17 |
+
onSuggestionClick,
|
| 18 |
}) {
|
| 19 |
const now = new Date();
|
| 20 |
|
|
|
|
| 32 |
return m.status === "expired" || days < 0;
|
| 33 |
}).length;
|
| 34 |
|
| 35 |
+
const goodStanding = memberships.filter(
|
| 36 |
+
(m) => m.status === "active"
|
| 37 |
+
).length;
|
| 38 |
|
| 39 |
const suggestionText =
|
| 40 |
totalMembers === 0
|
|
|
|
| 43 |
needAttention === 1 ? "" : "s"
|
| 44 |
} this week to improve retention.`;
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
return (
|
| 47 |
<div className="mb-8 rounded-3xl border border-purple-200 bg-gradient-to-r from-purple-50 to-purple-100/70 px-4 py-5 sm:px-6 sm:py-6">
|
| 48 |
<h2 className="text-sm font-semibold text-stone-900 mb-4 flex items-center gap-2">
|
|
|
|
| 53 |
</h2>
|
| 54 |
|
| 55 |
<div className="space-y-3">
|
| 56 |
+
{/* Row 1: renewing soon */}
|
| 57 |
+
<button
|
| 58 |
+
type="button"
|
| 59 |
+
onClick={onRenewingSoonClick}
|
| 60 |
+
className="w-full flex items-center justify-between rounded-2xl bg-white/90 px-4 py-3 shadow-sm hover:shadow-md transition-shadow cursor-pointer text-left"
|
| 61 |
>
|
| 62 |
<div className="flex items-center gap-3">
|
| 63 |
<div className="h-8 w-8 rounded-full bg-emerald-50 flex items-center justify-center">
|
| 64 |
<TrendingUp className="w-4 h-4 text-emerald-600" />
|
| 65 |
</div>
|
| 66 |
<p className="text-sm text-stone-700">
|
| 67 |
+
{renewingSoon} member{renewingSoon === 1 ? "" : "s"} are
|
| 68 |
+
due for renewal in the next 2 weeks
|
| 69 |
</p>
|
| 70 |
</div>
|
| 71 |
+
</button>
|
| 72 |
|
| 73 |
+
{/* Row 2: need attention */}
|
| 74 |
+
<button
|
| 75 |
+
type="button"
|
| 76 |
+
onClick={onNeedAttentionClick}
|
| 77 |
+
className="w-full flex items-center justify-between rounded-2xl bg-white/90 px-4 py-3 shadow-sm hover:shadow-md transition-shadow cursor-pointer text-left"
|
| 78 |
>
|
| 79 |
<div className="flex items-center gap-3">
|
| 80 |
<div className="h-8 w-8 rounded-full bg-amber-50 flex items-center justify-center">
|
|
|
|
| 85 |
immediate attention for renewal
|
| 86 |
</p>
|
| 87 |
</div>
|
| 88 |
+
</button>
|
| 89 |
|
| 90 |
+
{/* Row 3: good standing */}
|
| 91 |
+
<button
|
| 92 |
+
type="button"
|
| 93 |
+
onClick={onGoodStandingClick}
|
| 94 |
+
className="w-full flex items-center justify-between rounded-2xl bg-white/90 px-4 py-3 shadow-sm hover:shadow-md transition-shadow cursor-pointer text-left"
|
| 95 |
>
|
| 96 |
<div className="flex items-center gap-3">
|
| 97 |
<div className="h-8 w-8 rounded-full bg-blue-50 flex items-center justify-center">
|
|
|
|
| 102 |
maintaining good standing
|
| 103 |
</p>
|
| 104 |
</div>
|
| 105 |
+
</button>
|
| 106 |
|
| 107 |
{/* Suggestion row */}
|
| 108 |
+
<button
|
| 109 |
+
type="button"
|
| 110 |
+
onClick={onSuggestionClick}
|
| 111 |
+
className="mt-3 w-full rounded-2xl bg-purple-100 px-4 py-3 text-left hover:bg-purple-200/80 transition-colors cursor-pointer flex items-center gap-2"
|
| 112 |
+
>
|
| 113 |
+
<span className="inline-flex h-7 w-7 items-center justify-center rounded-full bg-yellow-100">
|
| 114 |
+
<Lightbulb className="w-4 h-4 text-yellow-500" />
|
| 115 |
+
</span>
|
| 116 |
+
<p className="text-sm text-purple-900">
|
| 117 |
+
<span className="font-semibold">Suggestion:</span> {suggestionText}
|
| 118 |
</p>
|
| 119 |
+
</button>
|
| 120 |
</div>
|
| 121 |
</div>
|
| 122 |
);
|