1import{r as i,j as t}from"./index-qel1lGKz.js";import{u as j}from"./useAdminCRUD-3PyI8A0w.js";import{A as w}from"./AdminTable-Bz1Vrrcu.js";import{D as E}from"./download-Cf9TBlYS.js";import"./AdminTooltip-dBS0CKXJ.js";import"./AdminLoadState-C2PI8MCZ.js";const N=[{key:"event_name",label:"Event"},{key:"full_name",label:"Name"},{key:"num_adults",label:"Adults"},{key:"num_children",label:"Children"},{key:"created_date",label:"Received",render:l=>l==null?void 0:l.slice(0,10)}],S={event_name:"Event",full_name:"Name",phone:"Phone",email:"Email",num_adults:"Adults",num_children:"Children",how_heard:"How Heard",mailing_list_opt_in:"Mailing List Opt-in",created_date:"Received"},C=["Event","Name","Email","Phone","Adults","Children","How Heard","Children Ages","Comments","Mailing List Opt-in","Received"],d="All Events";function D(){const{rows:l,loading:h}=j("EventRSVP","-created_date"),[m,p]=i.useState(null),[u,g]=i.useState(""),[r,f]=i.useState(d),v=i.useMemo(()=>{const e=new Set;return l.forEach(s=>{s.event_name&&e.add(s.event_name)}),Array.from(e).sort((s,a)=>s.localeCompare(a))},[l]),o=i.useMemo(()=>{const e=u.trim().toLowerCase();return l.filter(s=>{if(r!==d&&s.event_name!==r)return!1;if(!e)return!0;const a=(s.full_name||"").toLowerCase(),c=(s.event_name||"").toLowerCase();return a.includes(e)||c.includes(e)})},[l,u,r]),b=()=>{const e=o.map(n=>[n.event_name||"",n.full_name||"",n.email||"",n.phone||"",n.num_adults??"",n.num_children??"",n.how_heard||"",n.children_ages||"",n.comments||"",n.mailing_list_opt_in?"Yes":"No",n.created_date?n.created_date.slice(0,10):""]),s=[C,...e].map(n=>n.map(y=>`"${String(y).replace(/"/g,'""')}"`).join(",")).join(` 2`),a=new Blob([s],{type:"text/csv"}),c=URL.createObjectURL(a),x=document.createElement("a");x.href=c;const _=r!==d?`-${r.replace(/\s+/g,"-").toLowerCase()}`:"";x.download=`event-rsvps${_}-${new Date().toISOString().slice(0,10)}.csv`,x.click(),URL.revokeObjectURL(c)};return t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-2",children:[t.jsx("h1",{className:"text-lg font-bold text-gray-800",children:"Event RSVPs"}),t.jsxs("button",{onClick:b,disabled:h||o.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs bg-gray-100 hover:bg-gray-200 rounded border border-gray-300 disabled:opacity-50",children:[t.jsx(E,{className:"w-3.5 h-3.5"})," Export CSV"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[t.jsx("input",{type:"text",value:u,onChange:e=>g(e.target.value),placeholder:"Search by name or eventâ¦",className:"border border-gray-300 rounded px-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-gray-400 min-w-[220px]"}),t.jsxs("select",{value:r,onChange:e=>f(e.target.value),className:"border border-gray-300 rounded px-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-gray-400",children:[t.jsx("option",{value:d,children:"All Events"}),v.map(e=>t.jsx("option",{value:e,children:e},e))]}),t.jsxs("span",{className:"text-xs text-gray-400",children:[o.length," record",o.length!==1?"s":""]})]}),t.jsx(w,{rows:o,columns:N,loading:h,onEdit:e=>p(e)})]}),m&&t.jsxs("div",{className:"w-80 flex-shrink-0 bg-white border border-gray-200 rounded p-4 self-start sticky top-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h2",{className:"font-bold text-gray-800 text-sm",children:m.full_name}),t.jsx("button",{onClick:()=>p(null),className:"text-gray-400 hover:text-gray-700 text-lg leading-none",children:"Ã"})]}),t.jsx("dl",{className:"space-y-2 text-xs",children:Object.entries(S).map(([e,s])=>{const a=m[e];return a==null||a===""?null:t.jsxs("div",{children:[t.jsx("dt",{className:"font-semibold text-gray-500",children:s}),t.jsx("dd",{className:"text-gray-800 whitespace-pre-wrap break-words",children:String(a)})]},e)})})]})]})}export{D 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.