PageSourceSearch

https://trybrain.io/assets/_authenticated.organic-roi-Ce77ZSoM.js

js trybrain.io collected 2026-09-24 15:05:05 UTC 6,605 bytes, 1 lines download raw bytes

1import{z as E,D as I,E as W,e as v,P as B,r as N,f,j as e,L as $,ab as b,ac as w,ad as k,ae as y,af as j,N as C,C as R,a as _,b as F,c as T,d as L,aU as O,aV as V,aW as x,aX as n,aY as q,aZ as a,aD as A,k as S}from"./index-DHwBXtP2.js";import{D as K}from"./dollar-sign-CRMfgulg.js";import{T as U}from"./trending-up-BjyiYEVM.js";const z=E({method:"POST"}).middleware([I]).handler(W("src_lib_organic-roi_functions_ts--getOrganicRoiRollup_createServerFn_handler"));function i(t){return t.toLocaleString()}function p(t){return`$${(t/100).toLocaleString(void 0,{maximumFractionDigits:0})}`}function M(t){return!isFinite(t)||t===0?"—":`${(t*100).toFixed(2)}%`}function Z(){const t=v(B),c=v(z),[o,u]=N.useState(),[r,D]=N.useState(30),{data:h}=f({queryKey:["workspaces"],queryFn:()=>t({})}),m=o??h?.workspaces?.[0]?.id??h?.[0]?.id,{data:l,isLoading:H}=f({queryKey:["organic-roi",m,r],queryFn:()=>c({data:{workspaceId:m,days:r}}),enabled:!!m}),P=h?.workspaces??h??[];return e.jsxs("div",{className:"container mx-auto max-w-6xl px-4 py-6 space-y-6",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx($,{to:"/organic",className:"hover:underline",children:"Organic Matrix"}),e.jsx("span",{children:"/"}),e.jsx("span",{children:"ROI Rollup"})]}),e.jsxs("h1",{className:"text-2xl font-bold tracking-tight flex items-center gap-2 mt-1",children:[e.jsx(K,{className:"h-6 w-6"})," Organic ROI"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Views, clicks, leads, and revenue tied back to the exact angle, format, and hook that produced them."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{value:m??"",onValueChange:u,children:[e.jsx(w,{className:"w-[220px]",children:e.jsx(k,{placeholder:"Workspace"})}),e.jsx(y,{children:P.map(s=>e.jsx(j,{value:s.id,children:s.name},s.id))})]}),e.jsxs(b,{value:String(r),onValueChange:s=>D(Number(s)),children:[e.jsx(w,{className:"w-[140px]",children:e.jsx(k,{})}),e.jsxs(y,{children:[e.jsx(j,{value:"7",children:"Last 7 days"}),e.jsx(j,{value:"30",children:"Last 30 days"}),e.jsx(j,{value:"90",children:"Last 90 days"})]})]})]})]}),H||!l?e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{className:"h-24 w-full"}),e.jsx(C,{className:"h-64 w-full"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-6 gap-3",children:[e.jsx(d,{label:"Posts",value:i(l.totals.posts)}),e.jsx(d,{label:"Views",value:i(l.totals.views)}),e.jsx(d,{label:"Engagement",value:i(l.totals.engagement)}),e.jsx(d,{label:"Unique clicks",value:i(l.totals.unique_clicks)}),e.jsx(d,{label:"Conversions",value:i(l.totals.conversions)}),e.jsx(d,{label:"Revenue",value:p(l.totals.revenue_cents),accent:!0})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsx(g,{title:"By angle",rows:l.byAngle}),e.jsx(g,{title:"By format",rows:l.byFormat})]}),e.jsx(g,{title:"Top hooks",rows:l.byHook,description:"Hook lines ranked by revenue, then views.",keyLabel:"Hook"}),e.jsxs(R,{children:[e.jsxs(_,{children:[e.jsxs(F,{className:"flex items-center gap-2 text-base",children:[e.jsx(U,{className:"h-4 w-4"})," Per-post detail"]}),e.jsx(T,{children:"Highest revenue first. Empty revenue means the post drove traffic but no attributed conversions in this window."})]}),e.jsx(L,{className:"overflow-x-auto",children:e.jsxs(O,{children:[e.jsx(V,{children:e.jsxs(x,{children:[e.jsx(n,{children:"Post"}),e.jsx(n,{children:"Angle / Format"}),e.jsx(n,{className:"text-right",children:"Views"}),e.jsx(n,{className:"text-right",children:"Clicks"}),e.jsx(n,{className:"text-right",children:"CTR"}),e.jsx(n,{className:"text-right",children:"Conv."}),e.jsx(n,{className:"text-right",children:"Revenue"})]})}),e.jsx(q,{children:l.posts.length===0?e.jsx(x,{children:e.jsx(a,{colSpan:7,className:"text-center text-sm text-muted-foreground",children:"No published posts in this window."})}):l.posts.slice(0,50).map(s=>e.jsxs(x,{children:[e.jsxs(a,{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s.published_at?.slice(0,10)??"—"}),e.jsx("div",{className:"text-sm line-clamp-1 max-w-[240px]",children:s.hook_line??"(no hook)"}),s.permalink&&e.jsxs("a",{href:s.permalink,target:"_blank",rel:"noreferrer",className:"text-xs text-primary inline-flex items-center gap-1 hover:underline",children:["View ",e.jsx(A,{className:"h-3 w-3"})]})]}),e.jsx(a,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(S,{variant:"outline",children:s.angle??"—"}),e.jsx(S,{variant:"secondary",className:"w-fit",children:s.format??"—"})]})}),e.jsx(a,{className:"text-right font-mono",children:i(s.views)}),e.jsx(a,{className:"text-right font-mono",children:i(s.clicks)}),e.jsx(a,{className:"text-right font-mono",children:M(s.ctr)}),e.jsx(a,{className:"text-right font-mono",children:i(s.conversions)}),e.jsx(a,{className:"text-right font-mono",children:s.revenue_cents>0?p(s.revenue_cents):"—"})]},s.publish_id))})]})})]})]})]})}function d({label:t,value:c,accent:o}){return e.jsxs("div",{className:`rounded-lg border p-3 ${o?"bg-primary/5 border-primary/30":"bg-card"}`,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:"text-lg font-semibold tabular-nums",children:c})]})}function g({title:t,rows:c,description:o,keyLabel:u="Key"}){return e.jsxs(R,{children:[e.jsxs(_,{children:[e.jsx(F,{className:"text-base",children:t}),o&&e.jsx(T,{children:o})]}),e.jsx(L,{className:"overflow-x-auto",children:e.jsxs(O,{children:[e.jsx(V,{children:e.jsxs(x,{children:[e.jsx(n,{children:u}),e.jsx(n,{className:"text-right",children:"Posts"}),e.jsx(n,{className:"text-right",children:"Views"}),e.jsx(n,{className:"text-right",children:"Clicks"}),e.jsx(n,{className:"text-right",children:"Conv."}),e.jsx(n,{className:"text-right",children:"Revenue"})]})}),e.jsx(q,{children:c.length===0?e.jsx(x,{children:e.jsx(a,{colSpan:6,className:"text-center text-sm text-muted-foreground",children:"No data yet."})}):c.map(r=>e.jsxs(x,{children:[e.jsx(a,{className:"max-w-[280px] truncate",children:r.key}),e.jsx(a,{className:"text-right font-mono",children:i(r.posts)}),e.jsx(a,{className:"text-right font-mono",children:i(r.views)}),e.jsx(a,{className:"text-right font-mono",children:i(r.clicks)}),e.jsx(a,{className:"text-right font-mono",children:i(r.conversions)}),e.jsx(a,{className:"text-right font-mono",children:r.revenue_cents>0?p(r.revenue_cents):"—"})]},r.key))})]})})]})}export{Z as component};

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.