PageSourceSearch

https://www.eventmagic.co/assets/Events-BTAccj0_.js

js eventmagic.co collected 2026-10-05 08:55:24 UTC 9,067 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BwavspVJ.js","assets/index-DKjP-EgX.css"])))=>i.map(i=>d[i]);
2import{b as K,aK as J,u as Q,a1 as W,d as X,r as d,t as o,j as t,B as n,A as Z,C as y,e as E,x as S,h as ee,i as te,U as se,aL as ae,s as u,aM as re,g as ie,aN as ne,ab as oe}from"./index-BwavspVJ.js";import{D as le}from"./DescriptionAgendaDialog-DCJ_i9N9.js";import{R as ce,i as C}from"./registrationAvailability-FhcdBA8T.js";import{P as k}from"./plus-xYVt9KIq.js";import{U as de}from"./user-plus-CjgDJBuX.js";import{C as P}from"./clock-DeeNn58q.js";import"./rich-text-display-JDeHGbAQ.js";import"./purify.es-DP5U8-sc.js";import"./file-text--D7mlk18.js";import"./info-D7YDvFAw.js";function Ne(){const{profile:s,currentRole:i,isAdmin:ue}=K(),{contextPhoneNumber:v}=J(),m=Q(),R=W("/dashboard"),{toast:l}=X(),[_,q]=d.useState([]),[A,D]=d.useState(!0),[j,L]=d.useState([]),[w,N]=d.useState(null);d.useEffect(()=>{V(),f()},[s,v]),d.useEffect(()=>{const e=()=>{f()};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[]);const V=async()=>{if(s)try{let e,a;if(s.user_role==="host"){const r=v||s.phone_number;if(!r)return;const g=await o.from("events").select("*").eq("host_phone_number",r).order("event_date",{ascending:!0});e=g.data,a=g.error}else if(s.user_role==="admin"||s.user_role==="super_admin"){const r=await o.from("events").select("*").order("event_date",{ascending:!0});e=r.data,a=r.error}else{const r=await o.from("events").select("id, title, description, image_url, event_date, fee_amount, capacity, enable_waitlist, require_vetting, show_attendees, status, created_at, updated_at, enable_checkin, enable_community, enable_rsvp_channel, community_icon_url, qr_code, checkin_url, is_public, registration_manually_closed, registration_closes_at").in("status",["published","active","completed"]).eq("is_public",!0).order("event_date",{ascending:!0});e=r.data,a=r.error}if(a)throw a;q(e||[])}catch(e){console.error("Error fetching events:",e),l({title:"Error",description:"Failed to load events",variant:"destructive"})}finally{D(!1)}},f=async()=>{if(s)try{const{data:e,error:a}=await o.from("rsvps").select("*").eq("attendee_id",s.id).neq("status","incomplete");if(a)throw a;L(e||[])}catch(e){console.error("Error fetching RSVPs:",e)}},T=async e=>{if(!s)return;const{data:a,error:r}=await o.from("events").select("require_vetting").eq("id",e).single();if(r){l({title:"Error",description:"Failed to load event details",variant:"destructive"});return}const{data:g,error:G}=await o.from("event_questions").select("id").eq("event_id",e).limit(1);if(G){l({title:"Error",description:"Failed to load event questions",variant:"destructive"});return}if(g&&g.length>0){m(`/event/${e}/questions`);return}N(e);try{const c=a.require_vetting?"pending":"approved",{ensureProfileLinked:H}=await oe(async()=>{const{ensureProfileLinked:x}=await import("./index-BwavspVJ.js").then(I=>I.dP);return{ensureProfileLinked:x}},__vite__mapDeps([0,1]));await H();const{error:b}=await o.from("rsvps").insert({event_id:e,attendee_id:s.id,status:c});if(b)throw b;try{const x=localStorage.getItem("em_tracking_code");x&&o.rpc("increment_share_link_rsvps",{p_tracking_code:x}).then(()=>{try{localStorage.removeItem("em_tracking_code")}catch{}})}catch{}await f();const z=a.require_vetting?"Your registration is pending approval by the host.":"You've successfully registered for this event.";l({title:"Success!",description:z})}catch(c){console.error("Error creating RSVP:",c),c.code==="23505"?l({title:"Already Registered",description:"You've already registered for this event.",variant:"destructive"}):l({title:C(c)?"Registration closed":"Error",description:C(c)?ce:"Failed to register for event. Please try again.",variant:"destructive"})}finally{N(null)}},h=e=>j.some(a=>a.event_id===e),p=e=>{const a=j.find(r=>r.event_id===e);return(a==null?void 0:a.status)||null},U=e=>{const a=e.registration_manually_closed;return i==="attendee"&&!a&&!M(e.event_date)&&e.status==="published"&&!h(e.id)},B=e=>{const a=new Date(e);return{date:a.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric"}),time:a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}},F=e=>{switch(e){case"published":return t.jsx(u,{variant:"default",children:"Published"});case"draft":return t.jsx(u,{variant:"secondary",children:"Draft"});case"active":return t.jsx(u,{variant:"default",className:"bg-green-500",children:"Active"});case"completed":return t.jsx(u,{variant:"outline",children:"Completed"});default:return t.jsx(u,{variant:"outline",children:e})}},M=e=>new Date(e)<new Date,Y=e=>i==="admin"||i==="host"&&e.host_phone_number===(s==null?void 0:s.phone_number),$=()=>(s==null?void 0:s.user_role)==="admin"||(s==null?void 0:s.user_role)==="super_admin"?"All Events":(s==null?void 0:s.user_role)==="host"?"My Events":"Available Events",O=()=>i==="admin"?"Manage all events across the platform":i==="host"?"Manage your events and track attendance":"View all events across the network";return A?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):t.jsxs("div",{className:"space-y-6 animate-slide-up-fade",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(n,{variant:"ghost",size:"icon",onClick:()=>R(),children:t.jsx(Z,{className:"h-4 w-4"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-3xl font-bold",children:$()}),t.jsx("p",{className:"text-muted-foreground",children:O()})]})]}),(i==="host"||i==="admin")&&t.jsxs(n,{onClick:()=>m("/host/events"),className:"gap-2",children:[t.jsx(k,{className:"h-4 w-4"}),"Create Event"]})]}),_.length===0?t.jsx(y,{className:"text-center py-12",children:t.jsxs(E,{children:[t.jsx(S,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No events found"}),t.jsx("p",{className:"text-muted-foreground mb-4",children:(s==null?void 0:s.user_role)==="host"?"You haven't created any events yet.":"There are no events available at the moment."}),(i==="host"||i==="admin")&&t.jsxs(n,{onClick:()=>m("/host/events"),className:"gap-2",children:[t.jsx(k,{className:"h-4 w-4"}),"Create Your First Event"]})]})}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:_.map(e=>{const{date:a}=B(e.event_date);return t.jsxs(y,{className:"overflow-hidden hover:shadow-lg transition-shadow",children:[e.image_url&&t.jsx("div",{className:"w-full p-3 pb-0",children:t.jsx("img",{src:e.image_url,alt:e.title,className:"w-full h-auto max-h-48 object-contain rounded-[10px]"})}),t.jsxs(ee,{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(te,{className:"text-lg line-clamp-2",children:e.title}),F(e.status)]}),t.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(S,{className:"h-4 w-4"}),t.jsx("span",{children:a})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(se,{className:"h-4 w-4"}),t.jsx("span",{children:e.capacity})]}),e.fee_amount&&e.fee_amount>0&&t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ae,{className:"h-4 w-4"}),t.jsxs("span",{children:["$",e.fee_amount]})]})]}),e.require_vetting&&t.jsx(u,{variant:"outline",className:"w-fit",children:"Requires Approval"})]}),t.jsxs(E,{className:"space-y-4",children:[t.jsx(le,{title:e.title,de
2scription:e.description,variant:"link",triggerText:"View Description/Agenda"}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs(n,{variant:"outline",className:"w-full gap-2",onClick:()=>m(`/event/${e.id}`),children:[t.jsx(re,{className:"h-4 w-4"}),"View Event"]}),U(e)&&t.jsxs(n,{className:"w-full gap-2",onClick:()=>T(e.id),disabled:w===e.id,children:[t.jsx(de,{className:"h-4 w-4"}),w===e.id?"Registering...":"RSVP"]}),i==="attendee"&&!h(e.id)&&e.registration_manually_closed&&t.jsx(n,{variant:"outline",className:"w-full gap-2",disabled:!0,children:"Registration closed"}),h(e.id)&&p(e.id)==="approved"&&t.jsxs(n,{variant:"outline",className:"w-full gap-2 text-green-600 border-green-200 hover:bg-green-50",disabled:!0,children:[t.jsx(ie,{className:"h-4 w-4"}),"Registered"]}),h(e.id)&&p(e.id)==="pending"&&t.jsxs(n,{variant:"outline",className:"w-full gap-2 text-yellow-600 border-yellow-200 hover:bg-yellow-50",disabled:!0,children:[t.jsx(P,{className:"h-4 w-4"}),"Pending Approval"]}),h(e.id)&&(p(e.id)==="rejected"||p(e.id)==="declined")&&t.jsxs(n,{variant:"outline",className:"w-full gap-2 text-red-600 border-red-200 hover:bg-red-50",disabled:!0,children:[t.jsx(P,{className:"h-4 w-4"}),"Not Approved"]}),Y(e)&&t.jsxs(n,{variant:"outline",className:"w-full gap-2",onClick:()=>m(`/event/${e.id}/edit`),children:[t.jsx(ne,{className:"h-4 w-4"}),"Edit Event"]})]})]})]},e.id)})})]})}export{Ne 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.