// frontend/src/components/admin/AIInsightBox.jsx import React from "react"; import { Sparkles, TrendingUp, AlertTriangle, Users as UsersIcon, Lightbulb, } from "lucide-react"; import { differenceInDays } from "date-fns"; export default function AIInsightBox({ memberships = [], onRenewingSoonClick, onNeedAttentionClick, onGoodStandingClick, onSuggestionClick, }) { const now = new Date(); const totalMembers = memberships.length; const renewingSoon = memberships.filter((m) => { if (m.status !== "active" || !m.renewal_date) return false; const days = differenceInDays(new Date(m.renewal_date), now); return days >= 0 && days <= 14; }).length; const needAttention = memberships.filter((m) => { if (!m.renewal_date) return false; const days = differenceInDays(new Date(m.renewal_date), now); return m.status === "expired" || days < 0; }).length; const goodStanding = memberships.filter((m) => m.status === "active").length; const suggestionText = totalMembers === 0 ? "Once members join, I’ll highlight who needs your attention first." : `Focus on the ${needAttention} at-risk member${ needAttention === 1 ? "" : "s" } this week to improve retention.`; return (