1import{r,j as e,U as b,F as p,t as f,v as N,s as j,n as d,q as y,m as g,o as w,l as v}from"./index-DpgZMBVQ.js";const E=()=>{const[n,o]=r.useState([]),[i,x]=r.useState(!0),[l,m]=r.useState("");r.useEffect(()=>{(async()=>{try{const s=y(g(d,"course_registrations"),w("date","desc")),u=(await v(s)).docs.map(c=>({id:c.id,...c.data()}));o(u)}catch(s){console.error("Error fetching registrations:",s),o([])}finally{x(!1)}})()},[]);const h=n.filter(t=>t.studentName?.toLowerCase().includes(l.toLowerCase())||t.courseName?.toLowerCase().includes(l.toLowerCase()));return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsxs("h1",{className:"text-3xl font-black text-slate-800 flex items-center gap-3",children:[e.jsx(b,{className:"text-[#ec008c]"})," Inscripciones a Cursos"]}),e.jsxs("button",{className:"px-4 py-2 bg-slate-200 text-slate-700 font-bold rounded-xl hover:bg-slate-300 transition-colors flex items-center gap-2",children:[e.jsx(p,{size:18})," Exportar"]})]}),e.jsxs("div",{className:"relative mb-6",children:[e.jsx(f,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-400",size:18}),e.jsx("input",{type:"text",placeholder:"Buscar por alumno o curso...",value:l,onChange:t=>m(t.target.value),className:"pl-10 pr-4 py-2 rounded-xl border border-slate-200 focus:outline-none focus:border-[#ec008c] w-full max-w-md"})]}),i?e.jsx("div",{className:"text-center py-12 text-slate-500 font-bold",children:"Cargando inscripciones..."}):n.length===0?e.jsx("div",{className:"text-center py-12 bg-white rounded-2xl border border-slate-100",children:e.jsx("div",{className:"text-slate-400 mb-2",children:"No hay inscripciones registradas aún."})}):e.jsx("div",{className:"bg-white rounded-2xl border border-slate-100 overflow-hidden shadow-sm",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-100",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4 font-bold text-slate-600 text-sm",children:"Fecha"}),e.jsx("th",{className:"p-4 font-bold text-slate-600 text-sm",children:"Alumno"}),e.jsx("th",{className:"p-4 font-bold text-slate-600 text-sm",children:"Email"}),e.jsx("th",{className:"p-4 font-bold text-slate-600 text-sm",children:"Curso"}),e.jsx("th",{className:"p-4 font-bold text-slate-600 text-sm",children:"Estado"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-50",children:h.map(t=>e.jsxs("tr",{onClick:async()=>{if(t.read!==!0)try{await N(j(d,"course_registrations",t.id),{read:!0}),o(s=>s.map(a=>a.id===t.id?{...a,read:!0}:a))}catch(s){console.error("Error marking as read:",s)}},className:`hover:bg-slate-50/50 transition-colors cursor-pointer border-b border-slate-50 last:border-0 ${t.read!==!0?"bg-pink-50/50":""}`,children:[e.jsx("td",{className:`p-4 text-sm ${t.read!==!0?"font-bold text-[#ec008c]":"text-slate-500"}`,children:t.date?.toDate?t.date.toDate().toLocaleDateString():"N/A"}),e.jsx("td",{className:"p-4 font-bold text-slate-800",children:t.studentName}),e.jsx("td",{className:"p-4 text-sm text-slate-600",children:t.email}),e.jsx("td",{className:"p-4 text-sm text-[#5b2a86] font-bold",children:t.courseName||t.items&&t.items[0]?.name||"Curso sin nombre"}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-bold ${t.status==="confirmed"?"bg-green-100 text-green-700":"bg-yellow-100 text-yellow-700"}`,children:t.status==="confirmed"?"Confirmado":"Pendiente"})})]},t.id))})]})})]})};export{E 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.