PageSourceSearch

https://blueroots-production.up.railway.app/assets/events-page-C9mzctHh.js

js blueroots-production.up.railway.app collected 2026-10-03 12:13:04 UTC 5,861 bytes, 1 lines download raw bytes

1import{d as S,j as e}from"./tanstack-raftEBQU.js";import{u as F,r as c}from"./react-vendor-DG9jHnNQ.js";import{bk as q,bm as P,p as o,q as d,o as v,i as h,bg as O,aZ as z,F as A,d as L,a2 as G,b6 as k,ah as D,b0 as $}from"./index-CwEfLZlp.js";import{E as K,a as M}from"./event-share-modal-Bkl-CKxK.js";import{E as Q}from"./event-card-BKIgz8GE.js";import{G as p}from"./gradient-kpi-4B-mEvP1.js";import{g as m}from"./brand-y5J5nNhe.js";import{E as V}from"./external-link-DZc-C34W.js";import{L as B}from"./link-2-CYZaaWG9.js";import{P as _}from"./plus-B2Qz2fhA.js";import{T as Y}from"./trending-up-DqEPg851.js";import"./radix-B0zOOFBK.js";import"./charts-ycOWY838.js";import"./dnd-IADusAtS.js";import"./textarea-u-nF7bwL.js";import"./radio-group-Bh7y6P-3.js";import"./trash-2-D8NernoQ.js";import"./send-QQ2CR8ls.js";import"./popover-DXvunxK1.js";import"./command-H2UbYJlJ.js";import"./copy-DS2sWNpy.js";import"./event-time-eRCId-qs.js";import"./video-DUEppNB8.js";import"./pencil-BQDSAmsb.js";function be(){const{selectedCampaign:s}=q(),[,f]=F(),{toast:j}=P(),n=s?.id,u=s?.slug??"",g=s?.eventsEnabled===!0,[T,x]=c.useState(!1),[b,y]=c.useState(null),[i,N]=c.useState(null);c.useEffect(()=>{i&&!s?.slug&&console.warn("[EventShareModal] rendered without campaignSlug",{selectedCampaignId:s?.id,eventId:i.id})},[i,s?.slug,s?.id]);const[a,C]=c.useState(null),E=S({queryKey:[`/api/campaigns/${n}/events`,a],enabled:!!n&&g,queryFn:async()=>{const t=a?`?eventType=${encodeURIComponent(a)}`:"";return(await $("GET",`/api/campaigns/${n}/events${t}`)).json()}}),r=S({queryKey:[`/api/campaigns/${n}/events/stats`],enabled:!!n&&g,queryFn:async()=>(await $("GET",`/api/campaigns/${n}/events/stats`)).json()});function R(){y(null),x(!0)}function I(t){y(t),x(!0)}if(!n)return e.jsx("div",{className:"p-6",children:e.jsx(o,{className:"cc-card",children:e.jsx(d,{className:"pt-6 text-sm text-muted-foreground",children:"Select a campaign to manage events."})})});if(!g)return e.jsx("div",{className:"p-6",children:e.jsx(o,{className:"cc-card",children:e.jsxs(d,{className:"pt-6 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-semibold",children:[e.jsx(v,{className:"h-5 w-5 text-sky-600"})," Events"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Events are not enabled for this campaign. A master admin can turn them on under Campaign Features."})]})})});const w=E.data?.events??[],l=r.data,U=l?.attendanceRate==null?"—":`${Math.round(l.attendanceRate*100)}%`;return e.jsxs("div",{className:"p-4 sm:p-6 space-y-4 sm:space-y-6 overflow-y-auto h-full pb-24 sm:pb-6 relative z-[1]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-5 w-5 text-sky-600"}),e.jsx("h1",{className:"cc-page-title",children:"Events"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[u?e.jsxs(e.Fragment,{children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>window.open(`/c/${u}/events`,"_blank","noopener,noreferrer"),"data-testid":"button-view-public-events-page",children:[e.jsx(V,{className:"h-4 w-4 mr-1.5"})," View public page"]}),e.jsx(h,{variant:"outline",size:"sm","aria-label":"Copy public URL",title:"Copy public URL",onClick:async()=>{const t=O(`/c/${u}/events`);try{await navigator.clipboard.writeText(t),j({title:"Public URL copied",description:t})}catch{j({title:"Copy the public URL",description:t})}},"data-testid":"button-copy-public-events-url",children:e.jsx(B,{className:"h-4 w-4"})})]}):null,e.jsxs(h,{size:"sm",onClick:R,"data-testid":"button-new-event",children:[e.jsx(_,{className:"h-4 w-4 mr-1.5"})," New Event"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4","data-testid":"events-kpi-row",children:[e.jsx(p,{label:"Upcoming events",value:r.isLoading?"—":String(l?.upcoming??0),icon:v,gradient:m.voters,testId:"kpi-upcoming-events"}
1),e.jsx(p,{label:"RSVPs (30d)",value:r.isLoading?"—":String(l?.rsvps30d??0),icon:z,gradient:m.outreach,testId:"kpi-rsvps-30d"}),e.jsx(p,{label:"Attendance rate",value:r.isLoading?"—":U,icon:Y,gradient:m.email,testId:"kpi-attendance-rate"}),e.jsx(p,{label:"Active shifts",value:r.isLoading?"—":String(l?.activeShifts??0),icon:A,gradient:m.fundraising,testId:"kpi-active-shifts"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"events-type-filter",children:[e.jsx("button",{type:"button",onClick:()=>C(null),"data-testid":"chip-event-type-all","aria-pressed":a===null,children:e.jsx(L,{variant:a===null?"default":"outline",className:"cursor-pointer text-xs font-medium",children:"All types"})}),G.map(t=>e.jsx("button",{type:"button",onClick:()=>C(a===t?null:t),"data-testid":`chip-event-type-${t}`,"aria-pressed":a===t,children:e.jsx(L,{variant:a===t?"default":"outline",className:"cursor-pointer text-xs font-medium",children:k(t)})},t))]}),E.isLoading?e.jsx(o,{className:"cc-card",children:e.jsx(d,{className:"p-8 flex justify-center",children:e.jsx(D,{className:"h-5 w-5 animate-spin text-muted-foreground"})})}):w.length===0?e.jsx(o,{className:"cc-card",children:e.jsx(d,{className:"p-8 text-center text-sm text-muted-foreground",children:a?`No ${k(a).toLowerCase()} events. Clear the filter to see everything.`:"No events yet. Create your first event to get started."})}):e.jsx("div",{className:"grid gap-3 sm:gap-4 sm:grid-cols-2 xl:grid-cols-3","data-testid":"events-card-grid",children:w.map(t=>e.jsx(Q,{event:t,onOpen:()=>f(`/events/${t.id}`),onShare:()=>N(t),onEdit:()=>I(t)},t.id))}),e.jsx(K,{campaignId:n,event:b,open:T,onOpenChange:x,onSaved:t=>{!b&&t?.id&&f(`/events/${t.id}`)}}),i?e.jsx(M,{open:!!i,onOpenChange:t=>{t||N(null)},event:i,campaignId:n,campaignSlug:s?.slug??"",campaignName:s?.name??"",candidateName:s?.candidateName??null}):null]})}export{be 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.