1import{r as i,j as e,L as f,a4 as j,y as o,aO as n,a_ as N}from"./index-CzMEFmtw.js";import{P as y,a as _,C as v}from"./ui-BklIU2Vp.js";import{P as S}from"./plus-DZqQktxt.js";import{T as C}from"./triangle-alert-BAXlYilG.js";function R(){const[a,b]=i.useState([]),[c,m]=i.useState(!0),[h,g]=i.useState({}),x=async()=>{m(!0);const{data:s,error:t}=await o.from("webinars").select("id, slug, title, badge, price, starts_at, is_free, is_registrable, published, sort_order, attendee_count").order("sort_order");t&&n.error(t.message),b(s??[]),m(!1);const{data:r}=await o.from("webinar_registrations").select("webinar_id"),l={};(r??[]).forEach(d=>{d.webinar_id&&(l[d.webinar_id]=(l[d.webinar_id]??0)+1)}),g(l)};i.useEffect(()=>{x()},[]);const u=async()=>{var r;const s=(r=prompt("New webinar slug (URL-safe, e.g. 'dha-webinar-arabic'):"))==null?void 0:r.trim();if(!s)return;if(!/^[a-z0-9-]+$/.test(s)){n.error("Slug must be lowercase letters, numbers, and dashes only.");return}const{error:t}=await o.from("webinars").insert({slug:s,title:"New Webinar",badge:"NEW",short_description:"",language:"en",duration_minutes:90,published:!1,sort_order:a.length+1});if(t)return n.error(t.message);n.success("Webinar created (unpublished). Edit it now."),N(),x()},p=Date.now(),w=a.filter(s=>s.published&&s.starts_at&&new Date(s.starts_at).getTime()>p).length===0;return e.jsxs(y,{children:[e.jsx(_,{title:"Webinars",description:"Manage every webinar shown on the site â details, form questions, and registrations.",actions:e.jsxs("button",{onClick:u,className:"h-10 px-4 rounded-lg bg-[#F9A01B] text-white text-sm font-semibold flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4"})," New webinar"]})}),w&&!c&&e.jsxs("div",{className:"mb-6 rounded-xl border border-red-200 bg-red-50 p-4 flex items-start gap-3",children:[e.jsx(C,{className:"w-5 h-5 text-red-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{className:"font-semibold text-red-900",children:"No upcoming webinars scheduled"}),e.jsx("div",{className:"text-red-800 mt-0.5",children:"Every published webinar's date has passed (or none has a date). The countdown timer on the site will hide. Set a future start time on at least one webinar below to bring it back."})]})]}),e.jsx(v,{children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-left text-[11px] uppercase tracking-wider text-gray-500 border-b border-gray-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4",children:"Webinar"}),e.jsx("th",{className:"p-4",children:"Starts"}),e.jsx("th",{className:"p-4",children:"Status"}),e.jsx("th",{className:"p-4",children:"Registrations"})]})}),e.jsxs("tbody",{children:[a.map(s=>e.jsxs("tr",{className:"border-b border-gray-100 last:border-0 hover:bg-gray-50",children:[e.jsx("td",{className:"p-4",children:e.jsxs(f,{to:`/admin/webinars/${s.id}`,className:"block",children:[e.jsx("div",{className:"font-semibold text-gray-900",children:s.title}),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[s.badge," · /",s.slug,s.is_free&&" · Free"]})]})}),e.jsx("td",{className:"p-4 text-gray-700 text-xs",children:s.starts_at?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(j,{className:"w-3.5 h-3.5"}),new Date(s.starts_at).toLocaleString()]}):e.jsx("span",{className:"text-gray-400",children:"TBA"})}),e.jsx("td",{className:"p-4",children:e.jsx("span",{className:`inline-block text-[10px] font-bold px-2 py-0.5 rounded-full ${s.published?"bg-green-50 text-green-700":"bg-gray-100 text-gray-500"}`,children:s.published?"PUBLISHED":"DRAFT"})}),e.jsx("td",{className:"p-4 text-gray-700",children:h[s.id]??0})]},s.id)),!c&&a.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"p-8 text-center text-gray-500 text-sm",children:"No webinars yet."})})]})]})})]})}export{R 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.