1import{D as f,a as N,j as e,P as h,E as c,U as v,T as j,F as l,G as x,H as m,I as d,R as y,K as w,N as _,X as C,Y as T,O as z,Q as R,S as D,V as S,W as P,Z as u,_ as i,$,a0 as r,a1 as g}from"./index-CB3JrMnV.js";import{D as p}from"./dollar-sign-DQimCuj2.js";import{A as O}from"./arrow-down-right-Cwzz6sE6.js";function k(){return f({queryKey:["platform-dashboard"],queryFn:async()=>{const{data:s}=await N.get("/platform/dashboard");return s}})}function b(s){return`$${(s/100).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}`}function t({label:s,value:o,icon:n,sub:a}){return e.jsx(l,{className:"rounded-xl border-border/60 shadow-sm",children:e.jsx(d,{className:"p-5",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:s}),e.jsx("p",{className:"text-2xl font-bold tracking-tight",children:o}),a&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]}),e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(n,{className:"h-5 w-5 text-primary"})})]})})})}function H(){const{data:s,isLoading:o}=k();if(o||!s)return e.jsxs("div",{children:[e.jsx(h,{title:"Platform Dashboard",description:"Overview of all organizations and revenue"}),e.jsx("div",{className:"flex justify-center py-12 text-muted-foreground",children:"Loading..."})]});const n=s.revenue_by_plan.map(a=>({name:a.name,mrr:a.mrr/100,orgs:a.count}));return e.jsxs("div",{children:[e.jsx(h,{title:"Platform Dashboard",description:"Overview of all organizations and revenue"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 mb-8",children:[e.jsx(t,{label:"MRR",value:b(s.mrr),icon:p,sub:`${s.paying_organizations} paying`}),e.jsx(t,{label:"Total Orgs",value:s.total_organizations,icon:c,sub:`${s.active_organizations} active`}),e.jsx(t,{label:"Trial Orgs",value:s.trial_organizations,icon:c,sub:`${s.suspended_organizations} suspended`}),e.jsx(t,{label:"New Signups",value:s.new_signups,icon:v,sub:"This month"}),e.jsx(t,{label:"Conversion",value:`${s.conversion_rate}%`,icon:j,sub:"Trial to paid"}),e.jsx(t,{label:"Churn Rate",value:`${s.churn_rate}%`,icon:O,sub:"Last 30 days"})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2 mb-8",children:[e.jsxs(l,{children:[e.jsx(x,{children:e.jsx(m,{className:"text-base",children:"Revenue by Plan"})}),e.jsx(d,{children:n.length>0?e.jsx(y,{width:"100%",height:280,children:e.jsxs(w,{data:n,children:[e.jsx(_,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(C,{dataKey:"name",className:"text-xs"}),e.jsx(T,{className:"text-xs",tickFormatter:a=>`$${a}`}),e.jsx(z,{formatter:a=>[`$${a}`,"MRR"],contentStyle:{borderRadius:"8px",border:"1px solid var(--border)"}}),e.jsx(R,{dataKey:"mrr",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})}):e.jsx("p",{className:"text-sm text-muted-foreground py-12 text-center",children:"No revenue data yet"})})]}),e.jsxs(l,{children:[e.jsx(x,{children:e.jsx(m,{className:"text-base",children:"Platform Stats"})}),e.jsx(d,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 text-center",children:[e.jsx(D,{className:"h-6 w-6 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-2xl font-bold",children:s.total_students.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Students"})]}),e.jsxs("div",{className:"rounded-lg border p-4 text-center",children:[e.jsx(c,{className:"h-6 w-6 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-2xl font-bold",children:s.paying_organizations}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paying Orgs"})]}),e.jsxs("div",{className:"rounded-lg border p-4 text-center",children:[e.jsx(j,{className:"h-6 w-6 mx-auto text-muted-foreground mb-2"}),e.jsxs("p",{className:"text-2xl font-bold",children:[s.conversion_rate,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conversion Rate"})]}),e.jsxs("div",{className:"rounded-lg border p-4 text-center",children:[e.jsx(p,{className:"h-6 w-6 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-2xl font-bold",children:b(s.mrr*12)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"ARR"})]})]})})]})]}),e.jsxs(l,{children:[e.jsx(x,{children:e.jsx(m,{className:"text-base",children:"Top Organizations by Student Count"})}),e.jsx(d,{children:e.jsxs(S,{children:[e.jsx(P,{children:e.jsxs(u,{children:[e.jsx(i,{children:"Organization"}),e.jsx(i,{children:"Plan"}),e.jsx(i,{children:"Status"}),e.jsx(i,{className:"text-right",children:"Students"})]})}),e.jsxs($,{children:[s.top_organizations.map(a=>e.jsxs(u,{children:[e.jsx(r,{className:"font-medium",children:a.name}),e.jsx(r,{children:e.jsx(g,{variant:"outline",className:"capitalize",children:a.subscription_plan})}),e.jsx(r,{children:e.jsx(g,{variant:a.status==="active"?"default":"secondary",className:"capitalize",children:a.status})}),e.jsx(r,{className:"text-right font-medium",children:a.students_count})]},a.id)),s.top_organizations.length===0&&e.jsx(u,{children:e.jsx(r,{colSpan:4,className:"text-center text-muted-foreground py-8",children:"No organizations yet"})})]})]})})]})]})}export{H as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.