1import{d as C,j as e,L as o}from"./vendor-DG7D-edB.js";import{a as A,n as L,b as m,o as F,B as a,aS as D,v as P,a7 as r,ab as l,a0 as T,am as E,a8 as S,a9 as q,aa as R,h as n}from"./index-FIaEtjBH.js";import{u as K,F as $}from"./use-plan-features-CuhgPqSQ.js";import{A as p}from"./arrow-left-vTYID-Ji.js";import{R as f}from"./rocket-DE-jToQh.js";import{T as H}from"./trash-2-BeX74tkQ.js";import"./ui-BYpPUPUG.js";function J(){const{toast:x}=A(),g=L(),[,h]=C(),{hasFeature:v,isLoading:N}=K(),{data:c,isLoading:y}=m({queryKey:["/api/auth/me"]}),d=c?.user?.role==="admin"||c?.user?.isTenantAdmin,{data:t,isLoading:b}=m({queryKey:["/api/admin/boosts"],queryFn:async()=>{const s=await fetch("/api/admin/boosts");return s.ok?s.json():[]},enabled:d}),{data:M}=m({queryKey:["/api/boost-packages"],enabled:d}),u=F({mutationFn:async s=>{const i=await fetch(`/api/admin/boosts/${s}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"cancelled"})});if(!i.ok)throw new Error("Failed to cancel boost");return i.json()},onSuccess:()=>{x({title:"Boost cancelled"}),g.invalidateQueries({queryKey:["/api/admin/boosts"]})},onError:()=>{x({title:"Failed to cancel boost",variant:"destructive"})}});if(y||N)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-primary border-t-transparent rounded-full"})});if(!c?.user||!d)return e.jsx("div",{className:"min-h-[70vh] flex items-center justify-center px-4",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("h1",{className:"text-3xl font-display font-bold mb-4",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground mb-8",children:"You need admin privileges to access this page."}),e.jsx(o,{href:"/",children:e.jsx(a,{children:"Back to Home"})})]})});if(!v("eventBoosts")){const s=$.eventBoosts;return e.jsx("div",{className:"min-h-[70vh] flex items-center justify-center px-4",children:e.jsxs("div",{className:"text-center max-w-lg",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(D,{className:"w-8 h-8 text-gray-400"})}),e.jsx("h1",{className:"text-3xl font-display font-bold mb-4",children:s.name}),e.jsx("p",{className:"text-muted-foreground mb-2",children:s.description}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-8",children:["Available on: ",e.jsx("span",{className:"font-medium text-primary",children:s.availableOn})]}),e.jsxs("div",{className:"flex gap-3 justify-center",children:[e.jsxs(a,{variant:"outline",onClick:()=>h("/admin"),children:[e.jsx(p,{className:"w-4 h-4 mr-2"}),"Back to Admin"]}),e.jsxs(a,{onClick:()=>h("/admin/billing"),children:[e.jsx(P,{className:"w-4 h-4 mr-2"}),"View Plans"]})]})]})})}const w=t?.filter(s=>s.status==="active")||[],k=t?.filter(s=>s.status==="pending_payment")||[];t?.filter(s=>s.status==="expired"||s.status==="cancelled");const j=s=>s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"N/A",B=s=>{switch(s){case"active":return e.jsx(n,{className:"bg-green-500",children:"Active"});case"pending_payment":return e.jsx(n,{className:"bg-yellow-500",children:"Pending Payment"});case"expired":return e.jsx(n,{variant:"outline",children:"Expired"});case"cancelled":return e.jsx(n,{variant:"destructive",children:"Cancelled"});default:return e.jsx(n,{variant:"outline",children:s})}};return e.jsx("div",{className:"min-h-screen py-12 px-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx(o,{href:"/admin",children:e.jsxs(a,{variant:"ghost",size:"sm",className:"mb-4 gap-2",children:[e.jsx(p,{className:"w-4 h-4"})," Back to Dashboard"]})}),e.jsx("h1",{className:"text-4xl font-display font-bold mb-3",children:"Event Boosts"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Manage event boost promotions"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-4 mb-8",children:[e.jsx(r,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Boosts"}),e.jsx("p",{className:"text-3xl font-bold text-green-600",children:w.length})]}),e.jsx(f,{className:"w-8 h-8 text-green-500"})]})})}),e.jsx(r,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pending Payment"}),e.jsx("p",{className:"text-3xl font-bold text-yellow-600",children:k.length})]}),e.jsx(T,{className:"w-8 h-8 text-yellow-500"})]})})}),e.jsx(r,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Revenue"}),e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",((t?.reduce((s,i)=>s+(i.amountPaid||0),0)||0)/100).toFixed(2)]})]}),e.jsx(E,{className:"w-8 h-8 text-primary"})]})})})]}),e.jsxs(r,{children:[e.jsxs(S,{children:[e.jsx(q,{children:"All Boosts"}),e.jsx(R,{children:"View and manage all event boost promotions"})]}),e.jsx(l,{children:b?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):!t||t.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No boost purchases yet"}):e.jsx("div",{className:"space-y-4",children:t.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 bg-amber-100 rounded-lg",children:e.jsx(f,{className:"w-5 h-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(o,{href:`/events/${s.event?.slug}`,children:e.jsx("h3",{className:"font-semibold hover:text-primary",children:s.event?.title||"Unknown Event"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.package?.name," ⢠",j(s.startDate)," - ",j(s.endDate)]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"font-semibold",children:["$",((s.amountPaid||0)/100).toFixed(2)]}),B(s.status)]}),s.status==="active"&&e.jsx(a,{variant:"outline",size:"sm",onClick:()=>u.mutate(s.id),disabled:u.isPending,children:e.jsx(H,{className:"w-4 h-4"})})]})]},s.id))})})]})]})})}export{J 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.