PageSourceSearch

https://dr.green/assets/DAppAdminEvents-CKqkDmfk.js

js dr.green collected 2026-10-09 21:37:02 UTC 7,557 bytes, 1 lines download raw bytes

1import{r as l,j as t}from"./vendor-react-BShF8re-.js";import{B as h}from"./button-W3Hgui4M.js";import{I as m}from"./input-CFVZbgAM.js";import{L as r}from"./label-Chmg0Xmf.js";import{T as _}from"./textarea-BFwJhCcG.js";import{S as J,a as K,b as Q,c as W,d as X}from"./select-Cjaz2tek.js";import{D as Y,a as Z,d as R,b as ee,e as te}from"./dialog-DfM9V_hu.js";import{aj as ae,ak as se,al as ne,am as le}from"./api-gbp3BAW2.js";import{t as ie,M as oe}from"./main-BJJca7_A.js";import{s as p,O as ce,S as re,c as de,b as me,d as pe,f as w,e as ue}from"./OperationsShared-C8MgPSS0.js";import{P as xe}from"./plus-DhTiGw52.js";import{S as ge}from"./square-pen-Zmmlgmqb.js";import"./vendor-charts-BCab8LB1.js";import"./vendor-radix-C8nGYCau.js";import"./chevron-down-G8rEs2QL.js";import"./chevron-up-DJ3SOAga.js";import"./check-CaeGLKUY.js";import"./vendor-three-B861d5-k.js";import"./vendor-query-Ct1XpEdr.js";import"./vendor-router-Cdb6i2Qn.js";import"./vendor-motion-BJ3use6N.js";import"./vendor-supabase-BuKqWIvb.js";import"./vendor-helmet-cp87i0Vb.js";import"./vendor-wallet-uF1UZ9Kv.js";import"./card-CmQMi_QE.js";import"./badge-WBiuLmht.js";import"./search-DS-fRPZt.js";import"./loader-circle-FM97Wrz7.js";import"./chevron-left-DPE_tZ0N.js";const P=["UPCOMING","LIVE","COMPLETED","CANCELLED"],_e=()=>{const{toast:v}=ie(),[C,N]=l.useState([]),[o,L]=l.useState(null),[A,f]=l.useState(!0),[x,O]=l.useState(""),[j,I]=l.useState(1),[M,U]=l.useState(1),[y,F]=l.useState("all"),[G,u]=l.useState(!1),[d,S]=l.useState(null),[n,i]=l.useState({title:"",description:"",date:"",endDate:"",location:"",status:"UPCOMING",capacity:"",eventType:""}),[b,E]=l.useState(!1),g=l.useCallback(async()=>{var e,a;f(!0);try{const[s,c]=await Promise.all([ae({page:j,take:20}),se().catch(()=>null)]),q=(s==null?void 0:s.events)??(s==null?void 0:s.data)??(s==null?void 0:s.items)??(Array.isArray(s)?s:[]);N(q),U(((e=s==null?void 0:s.pageMetaDto)==null?void 0:e.pageCount)??((a=s==null?void 0:s.meta)==null?void 0:a.pageCount)??1),c&&L((c==null?void 0:c.summary)??(c==null?void 0:c.data)??c)}catch(s){console.error("[DAppAdminEvents]",s),N([])}f(!1)},[j]);l.useEffect(()=>{g()},[g]);const V=()=>{S(null),i({title:"",description:"",date:"",endDate:"",location:"",status:"UPCOMING",capacity:"",eventType:""}),u(!0)},D=e=>{S(e),i({title:e.title||"",description:e.description||"",date:e.date||e.startDate||"",endDate:e.endDate||"",location:e.location||e.venue||"",status:e.status||"UPCOMING",capacity:String(e.capacity??e.maxAttendees??""),eventType:e.eventType||e.type||""}),u(!0)},z=async()=>{E(!0);const e={title:n.title,description:n.description||void 0,date:n.date||void 0,startDate:n.date||void 0,endDate:n.endDate||void 0,location:n.location||void 0,venue:n.location||void 0,status:n.status,capacity:n.capacity?parseInt(n.capacity):void 0,eventType:n.eventType||void 0};try{d!=null&&d.id?(await ne(d.id,e),v({title:"Event updated"})):(await le(e),v({title:"Event created"})),u(!1),g()}catch{v({title:"Failed to save event",variant:"destructive"})}E(!1)},T=o?[{label:"Total Events",value:p(o.totalEvents??o.total)},{label:"Upcoming",value:p(o.upcoming??o.upcomingEvents),variant:"warning"},{label:"Live",value:p(o.live??o.liveEvents),variant:"success"},{label:"Completed",value:p(o.completed??o.completedEvents)}]:[],k=y==="all"?C:C.filter(e=>(e.status||"").toUpperCase()===y),B=x?k.filter(e=>(e.title||"").toLowerCase().includes(x.toLowerCase())||(e.location||e.venue||"").toLowerCase().includes(x.toLowerCase())):k,H=[{key:"title",label:"Event",render:e=>t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-sm",children:e.title||"Untitled"}),e.eventType&&t.jsx("p",{className:"text-[10px] text-muted-foreground capitalize",children:e.eventType})]})},{key:"date",label:"Date",render:e=>t.jsxs("div",{className:"text-xs",children:[t.jsx("p",{children:w(e.date||e.startDate)}),e.endDate&&t.jsxs("p",{className:"text-muted-foreground",children:["→ ",w(e.endDate)]})]})},{key:"location",label:"Location",render:e=>t.jsxs("span",{className:"text-xs flex items-center gap-1",children:[(e.location||e.venue)&&t.jsx(oe,{className:"w-3 h-3 text-muted-foreground"}),e.location||e.venue||"—"]})},{key:"capacity",label:"Capacity",render:e=>{const a=e.capacity??e.maxAttendees,s=e.attendees??e.attendeeCount??e.registrations;return t.jsxs("span",{className:"text-xs",children:[s!=null?`${p(s)}`:"—",a!=null?` / ${p(a)}`:""]})}},{key:"status",label:"Status",render:e=>t.jsx(ue,{status:e.status||"UPCOMING"})},{key:"actions",label:"",render:e=>t.jsx(h,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:a=>{a.stopPropagation(),D(e)},children:t.jsx(ge,{className:"w-3.5 h-3.5"})})}],$=[{label:"All",value:"all"},...P.map(e=>({label:e.charAt(0)+e.slice(1).toLowerCase(),value:e}))];return t.jsxs("div",{className:"space-y-6",children:[t.jsx(ce,{title:"Event Management",children:t.jsxs(h,{size:"sm",className:"gap-1.5",onClick:V,children:[t.jsx(xe,{className:"w-3.5 h-3.5"})," New Event"]})}),T.length>0&&t.jsx(re,{items:T}),t.jsx(de,{search:x,onSearch:O,onSubmitSearch:g,placeholder:"Search events…",filterValue:y,filterOptions:$,onFilter:F}),t.jsx(me,{columns:H,data:B,loading:A,emptyMessage:"No events found",onRowClick:D}),t.jsx(pe,{page:j,totalPages:M,onChange:I}),t.jsx(Y,{open:G,onOpenChange:u,children:t.jsxs(Z,{className:"bg-card border-border/30 max-w-md",children:[t.jsx(R,{children:t.jsx(ee,{children:d?"Edit Event":"Create Event"})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"Title"}),t.jsx(m,{value:n.title,onChange:e=>i(a=>({...a,title:e.target.value})),className:"bg-background"})]}),t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"Description"}),t.jsx(_,{value:n.description,onChange:e=>i(a=>({...a,description:e.target.value})),rows:3,className:"bg-background"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"Start Date"}),t.jsx(m,{type:"date",value:n.date,onChange:e=>i(a=>({...a,date:e.target.value})),className:"bg-background"})]}),t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"End Date"}),t.jsx(m,{type:"date",value:n.endDate,onChange:e=>i(a=>({...a,endDate:e.target.value})),className:"bg-background"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"Location"}),t.jsx(m,{value:n.location,onChange:e=>i(a=>({...a,location:e.target.value})),className:"bg-background",placeholder:"City, Country"})]}),t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"Event Type"}
1),t.jsx(m,{value:n.eventType,onChange:e=>i(a=>({...a,eventType:e.target.value})),className:"bg-background",placeholder:"e.g. Conference"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"Capacity"}),t.jsx(m,{type:"number",value:n.capacity,onChange:e=>i(a=>({...a,capacity:e.target.value})),className:"bg-background"})]}),t.jsxs("div",{children:[t.jsx(r,{className:"text-xs",children:"Status"}),t.jsxs(J,{value:n.status,onValueChange:e=>i(a=>({...a,status:e})),children:[t.jsx(K,{className:"bg-background",children:t.jsx(Q,{})}),t.jsx(W,{children:P.map(e=>t.jsx(X,{value:e,children:e.charAt(0)+e.slice(1).toLowerCase()},e))})]})]})]})]}),t.jsxs(te,{children:[t.jsx(h,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),t.jsx(h,{onClick:z,disabled:!n.title||b,children:b?"Saving…":d?"Update":"Create"})]})]})})]})};export{_e 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.