1import{c as N,l as C,r as d,u as T,j as e,C as t,B as u,Z as P,_ as L,y as $}from"./index-3YfI3l6d.js";import{T as E}from"./TimeRangeSelector-nXfpul8l.js";import{C as q}from"./circle-alert-DCz3Le9w.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const M=N("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const g=N("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);function U(a){return a==="archon"?"Archon ($99.99/mo)":a==="disciple"?"Disciple ($29.99/mo)":"None"}function _(a){switch(a){case"active":return"text-green-600 bg-green-100 dark:bg-green-900/30";case"trialing":return"text-yellow-600 bg-yellow-100 dark:bg-yellow-900/30";case"cancelled":case"canceled":return"text-red-600 bg-red-100 dark:bg-red-900/30";case"expired":return"text-gray-600 bg-gray-100 dark:bg-gray-900/30";case"lifetime":return"text-purple-600 bg-purple-100 dark:bg-purple-900/30";default:return"text-gray-600 bg-gray-100 dark:bg-gray-900/30"}}function c(){return e.jsx(t,{className:"p-6 bg-stone-800/50 border-stone-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-3 w-full",children:[e.jsx("div",{className:"h-3 w-2/3 bg-stone-700 rounded animate-pulse"}),e.jsx("div",{className:"h-7 w-1/2 bg-stone-700 rounded animate-pulse"})]}),e.jsx("div",{className:"w-8 h-8 bg-stone-700 rounded animate-pulse"})]})})}function B(){return e.jsxs(t,{className:"bg-stone-800/50 border-stone-700",children:[e.jsx("div",{className:"px-6 py-4 border-b border-stone-700",children:e.jsx("div",{className:"h-5 w-40 bg-stone-700 rounded animate-pulse"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-stone-700",children:[e.jsx("thead",{className:"bg-stone-900",children:e.jsx("tr",{children:["Customer","Plan","Status","Amount","Started"].map(a=>e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-stone-400 uppercase tracking-wider",children:a},a))})}),e.jsx("tbody",{className:"divide-y divide-stone-700",children:[...Array(5)].map((a,n)=>e.jsx("tr",{children:[...Array(5)].map((o,r)=>e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("div",{className:"h-4 w-24 bg-stone-700 rounded animate-pulse"})},r))},n))})]})})]})}function O(){const a=C(),[n,o]=d.useState(null),[r,f]=d.useState(null),{data:b,isLoading:y,isError:w,error:x,refetch:v}=T({queryKey:["admin-payments",n,r],queryFn:async()=>{let s="/api/admin/payments";const i=new URLSearchParams;n&&i.append("startTime",n),r&&i.append("endTime",r);const p=i.toString();p&&(s+=`?${p}`);const j=await fetch(s);if(!j.ok)throw new Error("Failed to fetch payments data");return j.json()}}),m=()=>{v(),a.info("Refreshing payment data...")},D=d.useCallback((s,i)=>{o(s),f(i)},[]);if(y)return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#D4AF37]",children:"Payments & Revenue"}),e.jsx("p",{className:"text-sm text-stone-400 mt-1",children:"Stripe subscription management and revenue tracking"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(c,{}),e.jsx(c,{}),e.jsx(c,{}),e.jsx(c,{})]}),e.jsx(B,{})]});if(w)return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#D4AF37]",children:"Payments & Revenue"}),e.jsx("p",{className:"text-sm text-stone-400 mt-1",children:"Stripe subscription management and revenue tracking"})]})}),e.jsxs(t,{className:"p-8 bg-stone-800/50 border-stone-700 text-center",children:[e.jsx(q,{className:"w-12 h-12 text-red-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Failed to Load Payment Data"}),e.jsx("p",{className:"text-sm text-stone-400 mb-4",children:x instanceof Error?x.message:"An unexpected error occurred"}),e.jsxs(u,{onClick:m,className:"bg-[#D4AF37]/20 hover:bg-[#D4AF37]/30 text-[#D4AF37] border border-[#D4AF37]/50",children:[e.jsx(P,{className:"w-4 h-4 mr-2"}),"Retry"]})]})]});const{mrr:A,totalSubscribers:F,activeByTier:l,trialCount:S,churnRate:k,recentSubscriptions:h}=b,R=s=>s==="archon"?99.99:s==="disciple"?29.99:0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#D4AF37]",children:"Payments & Revenue"}),e.jsx("p",{className:"text-sm text-stone-400 mt-1",children:"Stripe subscription management and revenue tracking"}),n&&e.jsxs("p",{className:"text-xs text-stone-500 mt-1 font-mono",children:["Filtered: ",new Date(n).toLocaleDateString()," â ",new Date(r||Date.now()).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 max-w-xs",children:e.jsx(E,{onTimeRangeChange:D})}),e.jsxs(u,{onClick:m,className:"bg-[#D4AF37]/20 hover:bg-[#D4AF37]/30 text-[#D4AF37] border border-[#D4AF37]/50",children:[e.jsx(M,{className:"w-4 h-4 mr-2"}),"Refresh Data"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(t,{className:"p-6 bg-stone-800/50 border-stone-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-stone-400",children:"Monthly Recurring Revenue"}),e.jsxs("p",{className:"text-2xl font-bold text-[#D4AF37]",children:["$",A.toFixed(2)]})]}),e.jsx(g,{className:"w-8 h-8 text-[#D4AF37]/50"})]})}),e.jsx(t,{className:"p-6 bg-stone-800/50 border-stone-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-stone-400",children:"Active Subscriptions"}),e.jsx("p",{className:"text-2xl font-bold text-[#D4AF37]",children:F})]}),e.jsx(L,{className:"w-8 h-8 text-[#D4AF37]/50"})]})}),e.jsx(t,{className:"p-6 bg-stone-800/50 border-stone-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-stone-400",children:"Active Trials"}),e.jsx("p",{className:"text-2xl font-bold text-[#D4AF37]",children:S})]}),e.jsx($,{className:"w-8 h-8 text-[#D4AF37]/50"})]})}),e.jsx(t,{className:"p-6 bg-stone-800/50 border-stone-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-stone-400",children:"Churn Rate"}),e.jsxs("p",{className:"text-2xl font-bold text-[#D4AF37]",children:[k,"%"]})]}),e.jsx(g,{className:"w-8 h-8 text-[#D4AF37]/50"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(t,{className:"p-6 bg-stone-800/50 border-stone-700",children:[e.jsx("h3",{className:"text-sm font-medium text-stone-400 mb-3",children:"Disciple"}),e.jsx("p",{className:"text-3xl font-bold text-[#D4AF37]",children:l.disciple}),e.jsxs("p",{className:"text-sm text-stone-500 mt-1",children:["$",(l.disciple*29.99).toFixed(2),"/mo MRR"]})]}),e.jsxs(t,{className:"p-6 bg-stone-800/50 border-stone-700",children:[e.jsx("h3",{className:"text-sm font-medium text-stone-400 mb-3",children:"Archon"}),e.jsx("p",{className:"text-3xl font-bold text-[#D4AF37]",children:l.archon}),e.jsxs("p",{className:"text-sm text-stone-500 mt-1",children:["$",(l.archon*99.99).toFixed(2),"/mo MRR"]})]})]}),e.jsxs(t,{className:"bg-stone-800/50 border-stone-700",children:[e.jsx("div",{className:"px-6 py-4 border-b border-stone-700",children:e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Recent Subscriptions"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-stone-700",children:[e.jsx("thead",{className:"bg-stone-900",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-stone-400 uppercase tracking-wider",children:"Customer"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-stone-400 uppercase tracking-wider",children:"Plan"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-stone-400 uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-stone-400 uppercase tracking-wider",children:"Amount"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-stone-400 uppercase tracking-wider",children:"Started"})]})}),e.jsx("tbody",{className:"divide-y divide-stone-700",children:h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-6 py-8 text-center text-sm text-stone-500",children:"No subscriptions foun
11d"})}):h.map(s=>e.jsxs("tr",{className:"hover:bg-stone-800/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-stone-300",children:s.email}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-stone-300",children:U(s.plan)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`inline-flex px-2.5 py-0.5 rounded-full text-xs font-medium ${_(s.status)}`,children:s.status})}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-stone-300",children:["$",R(s.plan).toFixed(2),"/mo"]}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-stone-400",children:s.joinedAt?new Date(s.joinedAt).toLocaleDateString():"â"})]},s.id))})]})})]}),e.jsxs(t,{className:"p-6 bg-[#D4AF37]/10 border-[#D4AF37]/30",children:[e.jsx("h3",{className:"text-lg font-semibold text-[#D4AF37] mb-2",children:"Stripe Integration"}),e.jsx("p",{className:"text-sm text-stone-300",children:"Payment data is fetched directly from the database, which is synced via Stripe webhooks."}),e.jsx("div",{className:"mt-4 flex gap-2",children:e.jsx("a",{href:"https://dashboard.stripe.com",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#D4AF37] hover:text-[#D4AF37]/80 underline",children:"Open Stripe Dashboard"})})]})]})}export{O as Payments};
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.