1import{e as E,u as F,f as q,j as e}from"./data-vendor-vk1v0Quf.js";import{r as c}from"./react-vendor-BKvR7kP7.js";import{c as k,j as B,B as j,T as z,S as H,I as O,o as Q,p as A,q as V,r as $,s as C,aa as K,Y as v}from"./index-DhiJfMte.js";import{A as G}from"./AdminLayout-DhjeY7NK.js";import{B as Y}from"./badge-ClzW_0OU.js";import{C as b,c as N}from"./card-S91eXzYI.js";import{T as Z,a as J,b as p,c as d,d as W,e as l}from"./table-D4PO6WDq.js";import{D as X}from"./download-jU6CR9UK.js";import{U as ee}from"./users-CZ3o6lXn.js";import{C as ae}from"./chevron-right-Dj03duT7.js";import{f as w}from"./format-cwXK75ha.js";import"./skeleton-CwRWBrAT.js";import"./avatar-CII0ItLT.js";import"./calendar-DLGTLifL.js";import"./package-Bp8AKodw.js";import"./chart-column-BxbmYcyy.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const te=k("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const se=k("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]),ne=["Badminton","Pickleball","Padel"];function be(){const[m,x]=c.useState(""),[u,M]=c.useState("all"),[D,P]=c.useState(new Set),{toast:g}=B(),R=E(),{data:S=[],isLoading:L}=F({queryKey:["admin-registrations"],queryFn:async()=>{const{data:a,error:t}=await v.from("tournament_registrations").select("*").order("created_at",{ascending:!1});if(t)throw t;return a}}),_=q({mutationFn:async({id:a,status:t})=>{const{error:n}=await v.from("tournament_registrations").update({payment_status:t}).eq("id",a);if(n)throw n},onSuccess:()=>{R.invalidateQueries({queryKey:["admin-registrations"]}),g({title:"Payment status updated"})},onError:()=>{g({title:"Failed to update status",variant:"destructive"})}}),o=c.useMemo(()=>S.filter(a=>{const t=u==="all"||a.sport===u,n=m.trim().toLowerCase(),r=!n||a.name.toLowerCase().includes(n)||a.mobile.toLowerCase().includes(n)||(a.email||"").toLowerCase().includes(n);return t&&r}),[S,u,m]),f=c.useMemo(()=>{const a=o.length,t=o.reduce((r,h)=>r+(h.entry_fee||0),0),n=o.filter(r=>r.payment_status==="paid").length;return{total:a,fees:t,paid:n}},[o]),I=async a=>{const{data:t,error:n}=await v.storage.from("tournament-docs").createSignedUrl(a,300);if(n||!(t!=null&&t.signedUrl)){g({title:"Could not open file",variant:"destructive"});return}window.open(t.signedUrl,"_blank")},T=()=>{const a=["Date","Name","Sport","Category","Mobile","Email","Partner Name","Partner Email","DOB","DUPR ID","Partner DUPR ID","Corporate ID","Entry Fee","Payment Status"],t=o.map(s=>[w(new Date(s.created_at),"yyyy-MM-dd HH:mm"),s.name,s.sport,s.category,s.mobile,s.email||"",s.partner_name||"",s.partner_email||"",s.dob||"",s.dupr_id||"",s.partner_dupr_id||"",s.corporate_id||"",String(s.entry_fee),s.payment_status]),n=[a,...t].map(s=>s.map(U=>`"${String(U).replace(/"/g,'""')}"`).join(",")).join(` 12`),r=new Blob([n],{type:"text/csv"}),h=URL.createObjectURL(r),y=document.createElement("a");y.href=h,y.download=`registrations-${w(new Date,"yyyy-MM-dd")}.csv`,y.click(),URL.revokeObjectURL(h)};return e.jsx(G,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Registrations"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Grand Racket Fest tournament entries"})]}),e.jsxs(j,{variant:"outline",onClick:T,disabled:!o.length,children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(b,{children:e.jsxs(N,{className:"flex items-center gap-3 p-4",children:[e.jsx(z,{className:"h-8 w-8 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:f.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total registrations"})]})]})}),e.jsx(b,{children:e.jsxs(N,{className:"flex items-center gap-3 p-4",children:[e.jsx(se,{className:"h-8 w-8 text-primary"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["â¹",f.fees.toLocaleStr
12ing("en-IN")]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Expected fees"})]})]})}),e.jsx(b,{children:e.jsxs(N,{className:"flex items-center gap-3 p-4",children:[e.jsx(ee,{className:"h-8 w-8 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:f.paid}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Marked paid"})]})]})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(H,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(O,{placeholder:"Search name, mobile or email...",className:"pl-9",value:m,onChange:a=>x(a.target.value)})]}),e.jsxs(Q,{value:u,onValueChange:M,children:[e.jsx(A,{className:"w-[180px]",children:e.jsx(V,{placeholder:"Sport"})}),e.jsxs($,{className:"bg-background z-50",children:[e.jsx(C,{value:"all",children:"All sports"}),ne.map(a=>e.jsx(C,{value:a,children:a},a))]})]})]}),e.jsx("div",{className:"rounded-lg border",children:e.jsxs(Z,{children:[e.jsx(J,{children:e.jsxs(p,{children:[e.jsx(d,{className:"w-8"}),e.jsx(d,{children:"Name"}),e.jsx(d,{children:"Sport"}),e.jsx(d,{children:"Category"}),e.jsx(d,{children:"Mobile"}),e.jsx(d,{children:"Fee"}),e.jsx(d,{children:"Status"}),e.jsx(d,{children:"Date"})]})}),e.jsx(W,{children:L?e.jsx(p,{children:e.jsx(l,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):o.length===0?e.jsx(p,{children:e.jsx(l,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No registrations found."})}):o.map(a=>{const t=D.has(a.id);return e.jsxs(c.Fragment,{children:[e.jsxs(p,{children:[e.jsx(l,{children:e.jsx(j,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>P(n=>{const r=new Set(n);return r.has(a.id)?r.delete(a.id):r.add(a.id),r}),children:t?e.jsx(K,{className:"h-4 w-4"}):e.jsx(ae,{className:"h-4 w-4"})})}),e.jsx(l,{className:"font-medium",children:a.name}),e.jsx(l,{children:a.sport}),e.jsx(l,{className:"max-w-[200px] truncate",children:a.category}),e.jsx(l,{children:a.mobile}),e.jsxs(l,{children:["â¹",a.entry_fee.toLocaleString("en-IN")]}),e.jsx(l,{children:e.jsx(Y,{variant:a.payment_status==="paid"?"default":"secondary",children:a.payment_status})}),e.jsx(l,{className:"whitespace-nowrap text-sm text-muted-foreground",children:w(new Date(a.created_at),"dd MMM yyyy")})]}),t&&e.jsx(p,{children:e.jsx(l,{colSpan:8,className:"bg-muted/40",children:e.jsxs("div",{className:"grid gap-x-8 gap-y-2 p-2 sm:grid-cols-2 lg:grid-cols-3 text-sm",children:[e.jsx(i,{label:"Email",value:a.email}),e.jsx(i,{label:"Partner name",value:a.partner_name}),e.jsx(i,{label:"Partner email",value:a.partner_email}),e.jsx(i,{label:"Date of birth",value:a.dob}),e.jsx(i,{label:"DUPR ID",value:a.dupr_id}),e.jsx(i,{label:"Partner DUPR ID",value:a.partner_dupr_id}),e.jsx(i,{label:"Corporate ID",value:a.corporate_id}),e.jsx(i,{label:"Match type",value:a.match_type}),e.jsx(i,{label:"Level",value:a.level}),e.jsxs("div",{className:"flex items-center gap-3 pt-2 sm:col-span-2 lg:col-span-3",children:[a.age_proof_url&&e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>I(a.age_proof_url),children:[e.jsx(te,{className:"h-4 w-4 mr-2"}),"Age proof"]}),e.jsx(j,{variant:a.payment_status==="paid"?"outline":"default",size:"sm",disabled:_.isPending,onClick:()=>_.mutate({id:a.id,status:a.payment_status==="paid"?"pending":"paid"}),children:a.payment_status==="paid"?"Mark as Pending":"Mark as Paid"})]})]})})},`${a.id}-detail`)]},a.id)})})]})})]})})}function i({label:m,value:x}){return x?e.jsxs("div",{children:[e.jsxs("span",{className:"text-muted-foreground",children:[m,": "]}),e.jsx("span",{className:"font-medium",children:x})]}):null}export{be 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.