1import{bv as h,j as e,B as f,_ as W,aq as N,R as x,T as Y,aa as $,ay as M,b3 as X,K as Z,al as ee,ad as ae,o as te,b1 as re,a5 as se,aw as L,b9 as le,M as ie,b5 as ne}from"./index-OosC7O28-v4.js";import{r as s}from"./react-vendor-Muxl3iU2-v4.js";import{Q as o}from"./ui-vendor-Bt0bJPpm-v4.js";import{E as de}from"./EmptyState-Dz0hqiOc-v4.js";import{A as oe}from"./AdminPageHeader-BRGHeeDK-v4.js";import"./swiper-vendor-CLjMzi4o-v4.js";import"./framer-motion-DbzRPpXx-v4.js";const A={title:"",description:"",event_date:"",start_time:"",end_time:"",venue:"",external_link:"",is_published:!0,flyer:null},fe=()=>{const[T,_]=s.useState([]),[B,w]=s.useState(!0),[v,R]=s.useState(""),[O,y]=s.useState(!1),[U,m]=s.useState(!1),[d,C]=s.useState(null),[q,F]=s.useState(!1),[P,S]=s.useState(null),[b,E]=s.useState(null),[t,p]=s.useState(A),[z,j]=s.useState(null),g=s.useRef(null);s.useEffect(()=>{k()},[]);const k=async()=>{w(!0);try{const a=await h.getAll();_(a.programs||[])}catch{o.error("Failed to load programs"),_([])}finally{w(!1)}},G=()=>{C(null),p(A),j(null),g.current&&(g.current.value=""),m(!0)},I=a=>{C(a),p({title:a.title||"",description:a.description||"",event_date:a.event_date?a.event_date.substring(0,10):"",start_time:a.start_time||"",end_time:a.end_time||"",venue:a.venue||"",external_link:a.external_link||"",is_published:a.is_published??!0,flyer:null}),j(a.flyer_full_url||null),g.current&&(g.current.value=""),m(!0)},n=a=>{const{name:l,value:i,type:r,checked:K,files:Q}=a.target;if(r==="file"){const c=Q[0]||null;if(p(u=>({...u,flyer:c})),c){const u=new FileReader;u.onloadend=()=>j(u.result),u.readAsDataURL(c)}else j((d==null?void 0:d.flyer_full_url)||null)}else p(r==="checkbox"?c=>({...c,[l]:K}):c=>({...c,[l]:i}))},V=async a=>{var l,i;a.preventDefault(),F(!0);try{const r=new FormData;r.append("title",t.title),r.append("description",t.description),r.append("event_date",t.event_date),t.start_time&&r.append("start_time",t.start_time),t.end_time&&r.append("end_time",t.end_time),t.venue&&r.append("venue",t.venue),t.external_link&&r.append("external_link",t.external_link),r.append("is_published",t.is_published?"1":"0"),t.flyer&&r.append("flyer",t.flyer),d?(r.append("_method","PUT"),await h.update(d.id,r),o.success("Program updated")):(await h.create(r),o.success("Program created")),m(!1),k()}catch(r){o.error(((i=(l=r.response)==null?void 0:l.data)==null?void 0:i.message)||"Failed to save program")}finally{F(!1)}},H=async()=>
1{try{await h.delete(b.id),o.success("Program deleted"),y(!1),E(null),k()}catch{o.error("Failed to delete program")}},J=async a=>{var l,i;if(window.confirm(`Send push notification for "${a.title}"?`)){S(a.id);try{const r=await h.notify(a.id);o.success(r.message||"Notifications sent"),k()}catch(r){o.error(((i=(l=r.response)==null?void 0:l.data)==null?void 0:i.message)||"Failed to send notification")}finally{S(null)}}},D=T.filter(a=>{var l,i;return((l=a.title)==null?void 0:l.toLowerCase().includes(v.toLowerCase()))||((i=a.venue)==null?void 0:i.toLowerCase().includes(v.toLowerCase()))});return e.jsxs("div",{children:[e.jsx(oe,{title:"Upcoming Programs",subtitle:"Manage programs and events that appear in the mobile app",icon:e.jsx(N,{}),children:e.jsx(f,{onClick:G,icon:e.jsx(W,{}),children:"New Program"})}),e.jsx("div",{className:"mb-6 max-w-sm",children:e.jsx(x,{placeholder:"Search programs...",value:v,onChange:a=>R(a.target.value),icon:e.jsx(Y,{})})}),B?e.jsx($,{}):D.length===0?e.jsx(de,{icon:e.jsx(N,{}),title:"No programs found",description:"Create the first upcoming program."}):e.jsx("div",{className:"bg-white dark:bg-dark-800 rounded-xl border border-gray-200 dark:border-dark-700 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-dark-700 bg-gray-50 dark:bg-dark-900/50",children:[e.jsx("th",{className:"text-left px-6 py-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Program"}),e.jsx("th",{className:"text-left px-6 py-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Date & Venue"}),e.jsx("th",{className:"text-left px-6 py-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Flyer"}),e.jsx("th",{className:"text-left px-6 py-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"text-left px-6 py-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Notified"}),e.jsx("th",{className:"text-right px-6 py-4 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-dark-700",children:D.map(a=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-dark-700/50 transition-colors",children:[e.jsxs("td",{className:"px-6 py-4 max-w-xs",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white truncate",children:a.title}),a.description&&e.jsx("div",{className:"text-xs text-gray-400 truncate mt-0.5",children:a.description})]}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx(N,{className:"text-gold-500 shrink-0",size:13}),e.jsx("span",{children:a.formatted_date||a.event_date})]}),a.venue&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-400 mt-0.5",children:[e.jsx(M,{size:11}),e.jsx("span",{className:"truncate max-w-[140px]",children:a.venue})]})]}),e.jsx("td",{className:"px-6 py-4",children:a.flyer_full_url?e.jsx("a",{href:a.flyer_full_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx("img",{src:a.flyer_full_url,alt:"flyer",className:"w-12 h-12 object-cover rounded-lg border border-gray-200 dark:border-dark-600"})}):e.jsx("div",{className:"w-12 h-12 rounded-lg bg-gray-100 dark:bg-dark-700 flex items-center justify-center",children:e.jsx(X,{size:16,className:"text-gray-300 dark:text-gray-600"})})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(Z,{variant:a.is_published?"success":"secondary",children:a.is_published?"Published":"Draft"})}),e.jsx("td",{className:"px-6 py-4",children:a.push_sent?e.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400 text-sm font-medium",children:[e.jsx(ee,{size:14})," Sent"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-gray-400 text-sm",children:[e.jsx(ae,{size:14})," Pending"]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>J(a),disabled:P===a.id,title:"Send push notification",className:"p-2 rounded-lg text-gray-400 hover:text-amber-500 hover:bg-amber-50 dark:hover:bg-amber-900/20 transition-colors",children:P===a.id?e.jsx("span",{className:"w-4 h-4 border-2 border-amber-500 border-t-transparent roun
1ded-full animate-spin inline-block"}):e.jsx(te,{size:16})}),e.jsx("button",{onClick:()=>I(a),className:"p-2 rounded-lg text-gray-400 hover:text-primary-600 hover:bg-primary-50 dark:hover:bg-primary-900/20 transition-colors",children:e.jsx(re,{size:16})}),e.jsx("button",{onClick:()=>{E(a),y(!0)},className:"p-2 rounded-lg text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:e.jsx(se,{size:16})})]})})]},a.id))})]})}),e.jsx(L,{isOpen:U,onClose:()=>m(!1),title:d?"Edit Program":"New Upcoming Program",size:"lg",children:e.jsxs("form",{onSubmit:V,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Title *"}),e.jsx(x,{name:"title",value:t.title,onChange:n,placeholder:"e.g. Easter Convention 2026",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),e.jsx("textarea",{name:"description",value:t.description,onChange:n,rows:3,placeholder:"Brief description of the program...",className:"w-full border border-gray-300 dark:border-dark-600 rounded-lg px-3 py-2 bg-white dark:bg-dark-700 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Event Date *"}),e.jsx(x,{type:"date",name:"event_date",value:t.event_date,onChange:n,required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Start Time"}),e.jsx(x,{type:"time",name:"start_time",value:t.start_time,onChange:n})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"End Time"}),e.jsx(x,{type:"time",name:"end_time",value:t.end_time,onChange:n})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(M,{size:13})," Venue"]})}),e.jsx(x,{name:"venue",value:t.venue,onChange:n,placeholder:"e.g. Grace Auditorium, Lagos"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(le,{size:13})," External Link"]})}),e.jsx(x,{name:"external_link",value:t.external_link,onChange:n,placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Flyer / Banner Image ",d?"(leave blank to keep existing)":""]}),z&&e.jsx("div",{className:"mb-2",children:e.jsx("img",{src:z,alt:"Flyer preview",className:"h-32 object-cover rounded-lg border border-gray-200 dark:border-dark-600"})}),e.jsx("input",{ref:g,type:"file",name:"flyer",onChange:n,accept:"image/jpeg,image/png,image/jpg,image/webp",className:"w-full text-sm text-gray-600 dark:text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100 dark:file:bg-primary-900/30 dark:file:text-primary-400"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"JPEG, PNG or WebP â max 4 MB"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",id:"is_published",name:"is_published",checked:t.is_published,onChange:n,className:"w-4 h-4 rounded text-primary-600 focus:ring-primary-500"}),e.jsxs("label",{htmlFor:"is_published",className:"text-sm font-medium text-gray-700 dark:text-gray-300 inline-flex items-center gap-1.5",children:[t.is_published?e.jsx(ie,{size:14}):e.jsx(ne,{size:14}),t.is_published?"Published (visible in app)":"Draft (hidden from app)"]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx(f,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),e.jsx(f,{type:"submit",loading:q,children:d?"Save Changes":"Create Program"})]})]})}),e.jsxs(L,{isOpen:O,onClose:()=>y(!1),title:"Delete Program",size:"sm",children:[e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:["Are you sure you want to delete ",e.jsx("strong",{className:"text-gray-900 dark:text-white",children:b==null?void 0:b.title}),"? This action cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(f,{variant:"secondary",onClick:()=>y(!1),children:"Cancel"}),e.jsx(f,{variant:"danger",onClick:H,children:"Delete"})]})]})]})};export{fe 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.