PageSourceSearch

https://healthserve.ae/assets/AdminWebinarEdit-DymvCFCu.js

js healthserve.ae collected 2026-10-04 02:40:06 UTC 16,204 bytes, 2 lines download raw bytes

1import{a$ as D,a6 as L,r as p,j as e,L as A,b0 as E,a_ as C,y as f,aO as j,X as S}from"./index-CzMEFmtw.js";import{P as N,a as $,C as _}from"./ui-BklIU2Vp.js";import{T as B}from"./trash-2-gzkfqCHP.js";import{S as F}from"./save-Bu384Y2v.js";import{P as q}from"./plus-DZqQktxt.js";import{G as T}from"./grip-vertical-BONnPuEz.js";import{D as P}from"./download-D1O7GOuA.js";function G(){const{id:x}=D(),i=L(),[l,s]=p.useState("details"),[c,d]=p.useState(null),[b,r]=p.useState(!0),o=async()=>{if(!x)return;r(!0);const{data:a,error:n}=await f.from("webinars").select("*").eq("id",x).maybeSingle();n&&j.error(n.message),d(a),r(!1)};return p.useEffect(()=>{o()},[x]),b?e.jsx(N,{children:e.jsx("div",{className:"text-sm text-gray-500",children:"Loading…"})}):c?e.jsxs(N,{children:[e.jsxs(A,{to:"/admin/webinars",className:"text-xs text-gray-500 hover:text-gray-900 flex items-center gap-1 mb-3",children:[e.jsx(E,{className:"w-3 h-3"})," Back to webinars"]}),e.jsx($,{title:c.title,description:`/${c.slug}`}),e.jsx("div",{className:"flex gap-1 mb-6 border-b border-gray-200",children:["details","form","registrations"].map(a=>e.jsx("button",{onClick:()=>s(a),className:`px-4 h-10 text-sm font-semibold capitalize border-b-2 -mb-px ${l===a?"border-[#F9A01B] text-[#B26800]":"border-transparent text-gray-500 hover:text-gray-800"}`,children:a==="form"?"Form fields":a},a))}),l==="details"&&e.jsx(R,{webinar:c,onSaved:()=>{C(),o()},onDeleted:()=>{C(),i("/admin/webinars")}}),l==="form"&&e.jsx(W,{webinarId:c.id}),l==="registrations"&&e.jsx(I,{webinarId:c.id,webinarSlug:c.slug})]}):e.jsx(N,{children:e.jsx("div",{className:"text-sm text-gray-500",children:"Not found."})})}const R=({webinar:x,onSaved:i,onDeleted:l})=>{const[s,c]=p.useState(x),[d,b]=p.useState(!1),r=t=>c({...s,...t}),o=async()=>{b(!0);const{error:t}=await f.from("webinars").update({title:s.title,badge:s.badge,short_description:s.short_description,price:s.price,language:s.language,starts_at:s.starts_at,duration_minutes:s.duration_minutes,is_free:s.is_free,attendee_count:s.attendee_count,includes:s.includes,audience:s.audience,live_badges:s.live_badges,primary_cta:s.primary_cta,secondary_cta:s.secondary_cta,is_registrable:s.is_registrable,published:s.published,sort_order:s.sort_order,status:s.status,countdown_label:s.countdown_label,show_countdown:s.show_countdown}).eq("id",s.id);if(b(!1),t)return j.error(t.message);j.success("Saved"),i()},a=async()=>{if(!confirm(`Delete "${s.title}"? All registrations and form fields will also be removed.`))return;const{error:t}=await f.from("webinars").delete().eq("id",s.id);if(t)return j.error(t.message);j.success("Deleted"),l()},n=t=>{if(!t)return"";const h=new Date(t),v=k=>String(k).padStart(2,"0");return`${h.getFullYear()}-${v(h.getMonth()+1)}-${v(h.getDate())}T${v(h.getHours())}:${v(h.getMinutes())}`},u=t=>t?new Date(t).toISOString():null;return e.jsxs(_,{className:"p-6 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(g,{label:"Title",span:2,children:e.jsx("input",{value:s.title,onChange:t=>r({title:t.target.value}),className:m})}),e.jsx(g,{label:"Badge (e.g. FREE WEBINAR, AED 5 ONLY)",children:e.jsx("input",{value:s.badge,onChange:t=>r({badge:t.target.value}),className:m})}),e.jsx(g,{label:"Price label (visible)",children:e.jsx("input",{value:s.price??"",onChange:t=>r({price:t.target.value||null}),className:m,placeholder:"Registration Fee"})}),e.jsx(g,{label:"Short description",span:2,children:e.jsx("textarea",{value:s.short_description,onChange:t=>r({short_description:t.target.value}),rows:3,className:m+" py-2 h-auto"})}),e.jsxs(g,{label:"Starts at (your local time)",children:[e.jsx("input",{type:"datetime-local",value:n(s.starts_at),onChange:t=>r({starts_at:u(t.target.value)}),className:m}),e.jsx("p",{className:"text-[11px] text-gray-500 mt-1",children:'Leave blank to show "TBA".'})]}),e.jsx(g,{label:"Duration (minutes)",children:e.jsx("input",{type:"number",value:s.duration_minutes,onChange:t=>r({duration_minutes:parseInt(t.target.value||"0",10)}),className:m})}),e.jsx(g,{label:"Language",children:e.jsxs("select",{value:s.language,onChange:t=>r({language:t.target.value}),className:m,children:[e.jsx("option",{value:"en",children:"English"}),e.jsx("option",{value:"ar",children:"Arabic"})]})}),e.jsx(g,{label:"Attendee count (displayed)",children:e.jsx("input",{type:"number",value:s.attendee_count,onChange:t=>r({attendee_count:parseInt(t.target.value||"0",10)}),className:m})}),e.jsx(g,{label:"Primary button label",children:e.jsx("input",{value:s.primary_cta,onChange:t=>r({primary_cta:t.target.value}),className:m})}),e.jsx(g,{label:"Secondary button label",children:e.jsx("input",{value:s.secondary_cta,onChange:t=>r({secondary_cta:t.target.value}),className:m})}),e.jsx(g,{label:"Display order (lower = first)",children:e.jsx("input",{type:"number",value:s.sort_order,onChange:t=>r({sort_order:parseInt(t.target.value||"0",10)}),className:m})})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gradient-to-br from-white to-gray-50 p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-extrabold text-gray-900",children:"Countdown & status"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Control the live timer and what visitors see on the webinar card and hero."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(g,{label:"Webinar status",children:e.jsxs("select",{value:s.status,onChange:t=>r({status:t.target.value}),className:m,children:[e.jsx("option",{value:"upcoming",children:"Upcoming — show countdown"}),e.jsx("option",{value:"live",children:'Live now — red "Live Now" badge'}),e.jsx("option",{value:"completed",children:"Completed — session ended"}),e.jsx("option",{value:"cancelled",children:"Cancelled — registrations hidden"})]})}),e.jsx(g,{label:"Countdown label",children:e.jsx("input",{value:s.countdown_label,onChange:t=>r({countdown_label:t.target.value}),className:m,placeholder:"Next Webinar Starts In"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-600 mr-1",children:"Qu
1ick set start time:"}),[{label:"+1 hour",ms:36e5},{label:"Tomorrow",ms:864e5},{label:"+3 days",ms:3*864e5},{label:"+1 week",ms:7*864e5}].map(t=>e.jsx("button",{type:"button",onClick:()=>r({starts_at:new Date(Date.now()+t.ms).toISOString()}),className:"h-8 px-3 rounded-lg border border-gray-200 bg-white text-xs font-semibold text-gray-700 hover:border-[#F9A01B] hover:text-[#B26800]",children:t.label},t.label)),e.jsx("button",{type:"button",onClick:()=>r({starts_at:null}),className:"h-8 px-3 rounded-lg border border-gray-200 bg-white text-xs font-semibold text-gray-500 hover:border-red-300 hover:text-red-600",children:"Clear (TBA)"})]}),e.jsx(y,{label:"Show countdown timer",checked:s.show_countdown,onChange:t=>r({show_countdown:t})}),e.jsx("div",{className:"text-xs text-gray-600 bg-white border border-gray-200 rounded-xl px-3 py-2",children:s.starts_at?`Timer counts down to ${new Date(s.starts_at).toLocaleString()} (your local time).`:"No start time set — visitors see TBA."})]}),e.jsx(w,{label:"What's included / topics",values:s.includes,onChange:t=>r({includes:t})}),e.jsx(w,{label:"Audience (who it's for)",values:s.audience,onChange:t=>r({audience:t})}),e.jsx(w,{label:"Live badges (chips)",values:s.live_badges,onChange:t=>r({live_badges:t})}),e.jsxs("div",{className:"flex flex-wrap gap-4 pt-2 border-t border-gray-100",children:[e.jsx(y,{label:"Free webinar",checked:s.is_free,onChange:t=>r({is_free:t})}),e.jsx(y,{label:"Accept registrations",checked:s.is_registrable,onChange:t=>r({is_registrable:t})}),e.jsx(y,{label:"Published (visible on site)",checked:s.published,onChange:t=>r({published:t})})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t border-gray-100",children:[e.jsxs("button",{onClick:a,className:"h-10 px-4 rounded-lg border border-red-200 text-red-600 text-sm flex items-center gap-1.5",children:[e.jsx(B,{className:"w-4 h-4"})," Delete"]}),e.jsxs("button",{onClick:o,disabled:d,className:"h-10 px-5 rounded-lg bg-[#F9A01B] text-white text-sm font-semibold flex items-center gap-2 disabled:opacity-60",children:[e.jsx(F,{className:"w-4 h-4"}),d?"Saving…":"Save changes"]})]})]})},W=({webinarId:x})=>{const[i,l]=p.useState([]),[s,c]=p.useState(!0),d=async()=>{c(!0);const{data:a}=await f.from("webinar_form_fields").select("*").eq("webinar_id",x).order("sort_order");l(a??[]),c(!1)};p.useEffect(()=>{d()},[x]);const b=async()=>{var t;const a=(t=prompt("Question label (e.g. 'How did you hear about us?'):"))==null?void 0:t.trim();if(!a)return;const n=a.toLowerCase().replace(/[^a-z0-9]+/g,"_").slice(0,40)+"_"+Math.random().toString(36).slice(2,6),{error:u}=await f.from("webinar_form_fields").insert({webinar_id:x,field_key:n,label:a,field_type:"text",required:!1,sort_order:i.length+1});if(u)return j.error(u.message);d()},r=async(a,n)=>{const{error:u}=await f.from("webinar_form_fields").update(n).eq("id",a.id);if(u)return j.error(u.message);d()},o=async a=>{if(!confirm(`Delete "${a.label}"?`))return;const{error:n}=await f.from("webinar_form_fields").delete().eq("id",a.id);if(n)return j.error(n.message);d()};return e.jsxs(_,{className:"p-6",children:[e.jsxs("div",{className:"mb-4 p-4 bg-blue-50 rounded-lg text-xs text-blue-900 leading-relaxed",children:[e.jsx("strong",{children:"Standard fields"})," (Full Name, Email, WhatsApp, Country, Profession, Experience, Consent) are always shown for every webinar. Add ",e.jsx("strong",{children:"custom questions"}),' here to collect additional info specific to this webinar. Answers are saved in the "extra" field of each registration.']}),e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900",children:s?"Loading…":`${i.length} custom question${i.length===1?"":"s"}`}),e.jsxs("button",{onClick:b,className:"h-9 px-3 rounded-lg bg-[#F9A01B] text-white text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(q,{className:"w-4 h-4"})," Add question"]})]}),e.jsxs("div",{className:"space-y-3",children:[i.map(a=>e.jsx("div",{className:"border border-gray-200 rounded-lg p-4 space-y-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(T,{className:"w-4 h-4 text-gray-400 mt-2"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("input",{value:a.label,onChange:n=>l(i.map(u=>u.id===a.id?{...u,label:n.target.value}:u)),onBlur:n=>
1r(a,{label:n.target.value}),className:m,placeholder:"Question label"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[e.jsxs("select",{value:a.field_type,onChange:n=>r(a,{field_type:n.target.value}),className:m,children:[e.jsx("option",{value:"text",children:"Short text"}),e.jsx("option",{value:"textarea",children:"Long text"}),e.jsx("option",{value:"email",children:"Email"}),e.jsx("option",{value:"tel",children:"Phone"}),e.jsx("option",{value:"select",children:"Dropdown"}),e.jsx("option",{value:"checkbox",children:"Checkbox"})]}),e.jsx("input",{value:a.placeholder??"",onChange:n=>l(i.map(u=>u.id===a.id?{...u,placeholder:n.target.value}:u)),onBlur:n=>r(a,{placeholder:n.target.value}),placeholder:"Placeholder text",className:m}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a.required,onChange:n=>r(a,{required:n.target.checked})}),"Required"]})]}),a.field_type==="select"&&e.jsx(w,{label:"Dropdown options",values:a.options,onChange:n=>r(a,{options:n})})]}),e.jsx("button",{onClick:()=>o(a),className:"text-red-500 hover:text-red-700",children:e.jsx(S,{className:"w-4 h-4"})})]})},a.id)),!s&&i.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-gray-500",children:"No custom questions yet. Standard fields are used."})]})]})},I=({webinarId:x,webinarSlug:i}
1)=>{const[l,s]=p.useState([]),[c,d]=p.useState(!0),b=async()=>{d(!0);const{data:o,error:a}=await f.from("webinar_registrations").select("*").eq("webinar_id",x).order("created_at",{ascending:!1});a&&j.error(a.message),s(o??[]),d(!1)};p.useEffect(()=>{b()},[x]);const r=()=>{const a=[["Date","Name","Email","WhatsApp","Country","Profession","Experience","Consent"].join(",")];for(const h of l)a.push([new Date(h.created_at).toISOString(),h.name,h.email,h.whatsapp??"",h.country??"",h.profession??"",h.experience??"",h.consent?"Yes":"No"].map(v=>`"${String(v).replace(/"/g,'""')}"`).join(","));const n=new Blob([a.join(`
2`)],{type:"text/csv"}),u=URL.createObjectURL(n),t=document.createElement("a");t.href=u,t.download=`${i}-registrations-${new Date().toISOString().slice(0,10)}.csv`,t.click(),URL.revokeObjectURL(u)};return e.jsxs(_,{children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900",children:c?"Loading…":`${l.length} registration${l.length===1?"":"s"}`}),e.jsxs("button",{onClick:r,disabled:l.length===0,className:"h-9 px-3 rounded-lg border border-gray-300 text-sm font-semibold flex items-center gap-1.5 disabled:opacity-50",children:[e.jsx(P,{className:"w-4 h-4"})," Export CSV"]})]}),e.jsx("div",{className:"overflow-x-auto",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-3",children:"Date"}),e.jsx("th",{className:"p-3",children:"Name"}),e.jsx("th",{className:"p-3",children:"Contact"}),e.jsx("th",{className:"p-3",children:"Country"}),e.jsx("th",{className:"p-3",children:"Profession"}),e.jsx("th",{className:"p-3",children:"Experience"})]})}),e.jsxs("tbody",{children:[l.map(o=>e.jsxs("tr",{className:"border-b border-gray-100 last:border-0",children:[e.jsx("td",{className:"p-3 text-xs text-gray-500 whitespace-nowrap",children:new Date(o.created_at).toLocaleDateString()}),e.jsx("td",{className:"p-3 font-semibold text-gray-900",children:o.name}),e.jsxs("td",{className:"p-3 text-xs",children:[e.jsx("div",{children:o.email}),o.whatsapp&&e.jsx("div",{className:"text-gray-500",children:o.whatsapp})]}),e.jsx("td",{className:"p-3 text-gray-700",children:o.country}),e.jsx("td",{className:"p-3 text-gray-700",children:o.profession}),e.jsx("td",{className:"p-3 text-gray-700",children:o.experience})]},o.id)),!c&&l.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-8 text-center text-sm text-gray-500",children:"No registrations yet."})})]})]})})]})},m="w-full h-10 px-3 rounded-lg border border-gray-300 text-sm focus:border-[#F9A01B] focus:ring-2 focus:ring-[#F9A01B]/15 outline-none transition bg-white",g=({label:x,span:i=1,children:l})=>e.jsxs("label",{className:`block ${i===2?"md:col-span-2":""}`,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:x}),l]}),y=({label:x,checked:i,onChange:l})=>e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-800 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:s=>l(s.target.checked)}),x]}),w=({label:x,values:i,onChange:l})=>{const[s,c]=p.useState("");return e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:x}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:i.map((d,b)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 h-8 rounded-full bg-gray-100 text-xs text-gray-800",children:[d,e.jsx("button",{onClick:()=>l(i.filter((r,o)=>o!==b)),className:"text-gray-500 hover:text-red-600",children:e.jsx(S,{className:"w-3 h-3"})})]},`${d}-${b}`))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:s,onChange:d=>c(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),s.trim()&&(l([...i,s.trim()]),c("")))},placeholder:"Type and press Enter to add",className:m}),e.jsx("button",{type:"button",onClick:()=>{s.trim()&&(l([...i,s.trim()]),c(""))},className:"h-10 px-3 rounded-lg border border-gray-300 text-sm",children:"Add"})]})]})};export{G 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.