"use client"; import { useEffect, useState } from "react"; import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip } from "recharts"; import { IndianRupee, TrendingUp, FileText, Download } from "lucide-react"; import { api, apiBase } from "@/lib/api"; import { inr } from "@/lib/utils"; const DONUT = ["#2563eb", "#10b981", "#f59e0b", "#8b5cf6", "#94a3b8"]; const STATUS: Record = { paid: "bg-emerald-50 text-emerald-700", pending: "bg-amber-50 text-amber-700", failed: "bg-rose-50 text-rose-700", refunded: "bg-slate-100 text-slate-600", }; export default function Revenue() { const [d, setD] = useState(null); useEffect(() => { api("/admin/revenue").then(setD).catch(() => {}); }, []); return (

Revenue & Finance

CSV
} tint="bg-emerald-50 text-emerald-600" /> } tint="bg-blue-50 text-blue-600" /> } tint="bg-violet-50 text-violet-600" /> } tint="bg-amber-50 text-amber-500" />

Revenue by Plan

{(d?.plan_breakdown ?? []).map((_: any, i: number) => )} inr(v)} />
{(d?.plan_breakdown ?? []).map((p: any, i: number) => ( {p.plan} ยท {inr(p.revenue)} ))}

All Invoices

{(d?.invoices ?? []).map((i: any) => ( ))} {(!d?.invoices || d.invoices.length === 0) && }
Invoice Organization Plan Total Status Date
{i.invoice_number} {i.org} {i.plan} {inr(i.total)} {i.status} {new Date(i.at).toLocaleDateString()}
No invoices yet.
); } function Kpi({ label, value, icon, tint }: any) { return (
{icon}
{label}
{value}
); }