PageSourceSearch

https://workait.com/assets/Revenue-DuarXvDh.js

js workait.com collected 2026-10-08 08:27:25 UTC 9,818 bytes, 1 lines download raw bytes

1import{fO as C,es as o,e9 as e,K as F,bT as R,P as l,Q as r,bc as L,S as w,T as _,cO as P,E as n,aM as D,eN as h,y as E,B as $,z as H}from"./index-D2yE0WFs.js";import{A as B}from"./AdminLayout-CuVddbA7.js";import{T as M}from"./trending-up-Bks0iuZo.js";import{H as k}from"./handshake-H0PcAUeO.js";import"./chart-column-Bi7_7fla.js";import"./banknote-v5qEX3yY.js";import"./activity-D50GHC8x.js";import"./users-314H31wg.js";const a=s=>`$${Number(s??0).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`,O=s=>new Date(`${s}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",year:"numeric",timeZone:"UTC"}),y=({name:s,logo:m})=>{var i;return e.jsxs(E,{className:"h-7 w-7 shrink-0",children:[m&&e.jsx($,{src:m,alt:""}),e.jsx(H,{className:"text-[10px] bg-[#5A60F1]/10 text-[#5A60F1] font-semibold",children:(i=(s??"?")[0])==null?void 0:i.toUpperCase()})]})},U=s=>s==="charged"?e.jsx(n,{className:"bg-emerald-100 text-emerald-800 hover:bg-emerald-100",children:"charged"}):s==="failed"?e.jsx(n,{variant:"destructive",children:"failed"}):s==="invoiced"?e.jsx(n,{className:"bg-amber-100 text-amber-800 hover:bg-amber-100",children:"invoiced"}):e.jsx(n,{variant:"secondary",children:s});function J(){C("Revenue");const[s,m]=o.useState(null),[i,A]=o.useState([]),[d,T]=o.useState([]),[x,u]=o.useState(!0),[p,j]=o.useState(null),g=async()=>{u(!0),j(null);const[t,c,N]=await Promise.all([h.rpc("admin_revenue_mrr"),h.rpc("admin_revenue_statements",{p_limit:50}),h.rpc("admin_revenue_unbilled")]),v=t.error||c.error||N.error;v&&j(v.message),m((t.data??[])[0]??null),A(c.data??[]),T(N.data??[]),u(!1)};o.useEffect(()=>{g()},[]);const f=d.filter(t=>t.active_30d),S=d.reduce((t,c)=>t+Number(c.would_bill||0),0),W=f.reduce((t,c)=>t+Number(c.would_bill||0),0),b=i.filter(t=>t.status==="failed");return e.jsx(B,{title:"Revenue",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Revenue"}),e.jsx("p",{className:"text-muted-foreground",children:"What the platform actually bills: live run-rate from Worker Payroll engagements, every statement and whether it went through, and access nobody is being billed for."})]}),e.jsxs(F,{variant:"outline",onClick:g,disabled:x,children:[e.jsx(R,{className:`h-4 w-4 mr-2 ${x?"animate-spin":""}`}),"Refresh"]})]}),p&&e.jsx(l,{className:"border-destructive/50",children:e.jsxs(r,{className:"p-4 text-sm text-destructive",children:[p,". If this mentions a missing function, paste migration 20260727130000 first."]})}),x?e.jsx("div",{className:"flex justify-center p-12",children:e.jsx(L,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(l,{className:"border-[#5A60F1]/30",children:e.jsxs(r,{className:"p-4",children:[e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(M,{className:"h-3 w-3"})," MRR (live engagements)"]}),e.jsx("div",{className:"text-2xl font-bold",children:a((s==null?void 0:s.mrr)??0)}),e.jsxs("div",{className:"text-[11px] text-muted-foreground mt-1",children:["ARR ",a(((s==null?void 0:s.mrr)??0)*12)]})]})}),e.jsx(l,{children:e.jsxs(r,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Team Workers"}),e.jsx("div",{className:"text-2xl font-bold",children:a((s==null?void 0:s.team_mrr)??0)}),e.jsxs("div",{className:"text-[11px] text-muted-foreground mt-1",children:[(s==null?void 0:s.team_workers)??0," active"]})]})}),e.jsx(l,{children:e.jsxs(r,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Hired Workers (run-rate)"}),e.jsx("div",{className:"text-2xl font-bold",children:a((s==null?void 0:s.hired_mrr)??0)}),e.jsxs("div",{className:"text-[11px] text-muted-foreground mt-1",children:[(s==null?void 0:s.hired_workers)??0," active · daily rate × 30"]})]})}),e.jsx(l,{children:e.jsxs(r,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Paying workplaces"}),e.jsx("div",{className:"text-2xl font-bold",children:(s==null?void 0:s.paying_workplaces)??0}),e.jsxs("div",{className:"text-[11px] text-muted-foreground mt-1 flex items-center gap-1",children:[e.jsx(k,{className:"h-3 w-3"}),(s==null?void 0:s.poc_workplaces)??0," on POC · ",a((s==null?void 0:s.poc_discount_monthly)??0),"/mo discount"]})]})})]}),((s==null?void 0:s.free_window_workers)??0)>0&&e.jsx(l,{className:"border-[#5A60F1]/30",children:e.jsxs(r,{className:"p-4 text-sm flex items-start gap-2",children:[e.jsx(k,{className:"h-4 w-4 text-[#5A60F1] mt-0.5 shrink-0"}),e.jsxs("span",{children:[e.jsxs("b",{children:[a((s==null?void 0:s.free_window_monthly)??0),"/month"]})," given away by POC free windows:"," ",s==null?void 0:s.free_window_workers," Team Worker(s) across ",s==null?void 0:s.free_window_workplaces," workplace(s) are working with no paywall until their window closes. Deliberate, and it ends on its own."]})]})}),d.length===0&&e.jsx(l,{children:e.jsxs(r,{className:"p-4 text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"No unbilled access: every open paywall on a billable workplace has an engagement behind it."]})}),d.length>0&&e.jsxs(l,{className:"border-amber-300",children:[e.jsxs(w,{className:"pb-2",children:[e.jsxs(_,{className:"text-base flex items-center gap-2",children:[e.jsx(P,{className:"h-4 w-4 text-amber-600"}),"Working with nothing to bill: ",d.length," relationship(s), ",f.length," active in the last 30 days"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["The paywall is o
1pen (marked paid) but there is no engagement and no subscription behind these, so they never reach a statement and no cost alert can see them. Worth ",a(W),"/month active, ",a(S),"/month in total if every one were billed. Grandfather them deliberately, or convert them."]})]}),e.jsx(r,{className:"p-0",children:e.jsx("div",{className:"max-h-80 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-muted/40",children:e.jsxs("tr",{className:"border-b text-left",children:[e.jsx("th",{className:"p-3 font-semibold",children:"Workplace"}),e.jsx("th",{className:"p-3 font-semibold",children:"Worker"}),e.jsx("th",{className:"p-3 font-semibold",children:"Kind"}),e.jsx("th",{className:"p-3 font-semibold text-right",children:"Would bill"}),e.jsx("th",{className:"p-3 font-semibold",children:"Last 30d"}),e.jsx("th",{className:"p-3 font-semibold",children:"Since"})]})}),e.jsx("tbody",{children:d.map(t=>e.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-muted/20",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{name:t.workplace_name,logo:t.workplace_logo_url}),e.jsx("span",{className:"truncate",children:t.workplace_name??"—"})]})}),e.jsx("td",{className:"p-3",children:t.worker_name??"—"}),e.jsx("td",{className:"p-3",children:e.jsx(n,{variant:"outline",children:t.is_team?"Team":"Hired"})}),e.jsx("td",{className:"p-3 text-right font-mono",children:a(t.would_bill)}),e.jsx("td",{className:"p-3",children:t.active_30d?e.jsx(n,{className:"bg-emerald-100 text-emerald-800 hover:bg-emerald-100",children:"active"}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"dormant"})}),e.jsx("td",{className:"p-3 text-muted-foreground text-xs",children:new Date(t.since).toLocaleDateString(void 0,{year:"numeric",month:"short"})})]},`${t.workplace_id}-${t.worker_id}`))})]})})})]}),e.jsxs(l,{children:[e.jsxs(w,{className:"pb-2",children:[e.jsxs(_,{className:"text-base flex items-center gap-2",children:[e.jsx(D,{className:"h-4 w-4 text-[#5A60F1]"}),"Monthly Worker statements",b.length>0&&e.jsxs(n,{variant:"destructive",className:"ml-1",children:[b.length," failed"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Issued on the 1st, charged on the 3rd. A failed run means Stripe dunning has taken over."})]}),e.jsx(r,{className:"p-0",children:i.length===0?e.jsx("div",{className:"p-12 text-center text-muted-foreground",children:"No statements yet. The first run lands on the 1st of next month."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/40 text-left",children:[e.jsx("th",{className:"p-3 font-semibold",children:"Workplace"}),e.jsx("th",{className:"p-3 font-semibold",children:"Period"}),e.jsx("th",{className:"p-3 font-semibold text-right",children:"Total"}),e.jsx("th",{className:"p-3 font-semibold text-right",children:"Lines"}),e.jsx("th",{className:"p-3 font-semibold",children:"Status"}),e.jsx("th",{className:"p-3 font-semibold",children:"Note"})]})}),e.jsx("tbody",{children:i.map(t=>e.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-muted/20",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{name:t.workplace_name,logo:t.workplace_logo_url}),e.jsx("span",{className:"truncate",children:t.workplace_name??"—"})]})}),e.jsx("td",{className:"p-3",children:O(t.period_start)}),e.jsx("td",{className:"p-3 text-right font-mono font-semibold",children:a(t.total_amount)}),e.jsx("td",{className:"p-3 text-right text-muted-foreground",children:t.line_count}),e.jsx("td",{className:"p-3",children:U(t.status)}),e.jsx("td",{className:"p-3 text-xs text-muted-foreground max-w-64 truncate",title:t.error_message??"",children:t.error_message??(t.stripe_invoice_id?t.stripe_invoice_id:"")})]},t.run_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.