1import{r as h,j as e}from"./vendor-radix-DLGwGdby.js";import{q as I,C as d,b as m,c as v,d as u,e as i,g as y,I as N,B as R,D as g,h as B,A as P}from"./index-Cz1Nuibl.js";import{T as k,a as O,b as p,c as D,d as q,e as j}from"./table-DxmE8Wef.js";import{P as G}from"./PageHeader-DadO5fKg.js";import{b9 as H,_ as S}from"./vendor-lucide-BWW0XcuW.js";import{f as C,c as U,e as K}from"./vendor-datefns-CU7NMMYW.js";import"./vendor-recharts-dzgay_RI.js";const $={startup:"Startup",mentor:"Mentor",service_provider:"Service Provider",entity:"Enabler",enabler:"Enabler",investor:"Investor",other:"Other / No Role"},n=["registrations","approved","rejected","awaiting_info","feedback_sent"],E={registrations:"Registrations",approved:"Approved",rejected:"Rejected",awaiting_info:"Info Requested",feedback_sent:"Feedback Sent"},_=new Date,z=C(U(_),"yyyy-MM-dd"),Q=C(K(_),"yyyy-MM-dd");function Y({label:a,value:x}){return e.jsxs(d,{children:[e.jsx(m,{className:"pb-2",children:e.jsx(u,{children:a})}),e.jsx(i,{children:e.jsx("p",{className:"text-3xl font-bold tabular-nums",children:x.toLocaleString()})})]})}function J(){return e.jsxs(d,{children:[e.jsx(m,{className:"pb-2",children:e.jsx(g,{className:"h-4 w-24"})}),e.jsx(i,{children:e.jsx(g,{className:"h-8 w-16"})})]})}function ae(){const[a,x]=h.useState(z),[l,w]=h.useState(Q),[r,T]=h.useState(null),{data:t,isLoading:o,isError:F,error:L,refetch:A}=I({queryKey:["admin-registration-report",r?.startDate,r?.endDate],queryFn:()=>{const s=new URLSearchParams({startDate:r.startDate,endDate:r.endDate});return B.get(`${P}/admin/reports/registrations?${s}`)},enabled:r!==null,retry:!1}),M=()=>{T({startDate:a,endDate:l})},f=["startup","mentor","service_provider","enabler","investor","other"];return e.jsxs("div",{className:"p-4 sm:p-6 space-y-6",children:[e.jsx(G,{title:"Registration Report",description:"Generate a summary of registrations and validation actions for any date range"}),e.jsxs(d,{children:[e.jsxs(m,{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-5 w-5"}),"Date Range"]}),e.jsx(u,{children:"Select a start and end date (up to 366 days)"})]}),e.jsx(i,{children:e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"report-start-date",children:"Start Date"}),e.jsx(N,{id:"report-start-date",type:"date",value:a,onChange:s=>x(s.target.value),max:l||void 0,"data-testid":"input-start-date"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(y,{htmlFor:"report-end-date",children:"End Date"}),e.jsx(N,{id:"report-end-date",type:"date",value:l,min:a||void 0,onChange:s=>w(s.target.value),"data-testid":"input-end-date"})]}),e.jsx(R,{onClick:M,disabled:!a||!l||o,"data-testid":"button-generate-report",children:o?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 me-2 animate-spin"}),"Generatingâ¦"]}):"Generate Report"})]})})]}),r&&e.jsxs(e.Fragment,{children:[o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-4",children:n.map(s=>e.jsx(J,{},s))}),e.jsx(d,{children:e.jsx(i,{className:"pt-6",children:e.jsx(g,{className:"h-48 w-full"})})})]}),F&&e.jsx(d,{className:"border-destructive",children:e.jsx(i,{className:"pt-6",children:e.jsx("p",{className:"text-destructive text-sm font-medium",children:L?.message??"Failed to generate report. Please check your date range and try again."})})}),t&&!o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Showing data for"," ",e.jsx("span",{className:"font-medium text-foreground",children:t.period.startDate})," ","â"," ",e.jsx("span",{className:"font-medium text-foreground",children:t.period.endDate})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-4",children:n.map(s=>e.jsx(Y,{label:E[s],value:t.totals[s]},s))})]}),e.jsxs(d,{children:[e.jsxs(m,{children:[e.jsx(v,{children:"Breakdown by Role"}),e.jsx(u,{children:"Each metric split by role. Registrations are counted once per role held. Approved / Rejected / Info Requested / Feedback Sent reflect the role acted on."})]}),e.jsxs(i,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(k,{children:[e.jsx(O,{children:e.jsxs(p,{children:[e.jsx(D,{children:"Role"}),n.map(s=>e.jsx(D,{className:"text-end",children:E[s]},s))]})}),e.jsxs(q,{children:[f.map(s=>n.some(c=>t.by_role[c][s]>0)?e.jsxs(p,{children:[e.jsx(j,{className:"font-medium",children:$[s]}),n.map(c=>e.jsx(j,{className:"text-end tabular-nums",children:t.by_role[c][s].toLocaleStr
1ing()},c))]},s):null),f.every(s=>n.every(b=>t.by_role[b][s]===0))&&e.jsx(p,{children:e.jsx(j,{colSpan:6,className:"text-center py-6 text-muted-foreground",children:"No data for the selected period"})})]})]})}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>A(),"data-testid":"button-refresh",children:[e.jsx(S,{className:"h-3.5 w-3.5 me-1.5"}),"Refresh"]})})]})]})]})]})]})}export{ae 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.