PageSourceSearch

https://slantapp.ai/assets/MajorityReportLibrary-iIs6omXF.js

js slantapp.ai collected 2026-10-05 15:06:03 UTC 12,732 bytes, 1 lines download raw bytes

1import{u as F,f as I,r as g,W as M,j as e,C as E,a as B,B as o,_ as C,O as w,a8 as U,a4 as L,aA as _,b as z,I as V,c as q,F as H,Q as O,$ as G,a0 as K,a1 as Q,a2 as W,a3 as Y,a7 as X,X as J,a5 as Z}from"./index-tc5-nNLC.js";import{T as ee}from"./textarea-DN2rY_yY.js";import{L as k}from"./label-MwGx_WS4.js";import{T as te,a as ae,b as D,c as p,d as se,e as b}from"./table-Azv99rWQ.js";import{L as T}from"./lock-CWiCoas5.js";import{E as S}from"./external-link-wMXh6D17.js";import{D as R}from"./download-DtCkiRGd.js";import{M as A}from"./mail-DG8jvVe4.js";import{S as ie}from"./shield-check-LwYRIJhL.js";import{C as re}from"./circle-check-B8vEXYAG.js";function $(s){return s?new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}function ne(s){return!s||s<=0?"—":`$${(s/100).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0})}`}function le(s){return s.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function de({status:s}){const n={active:{label:"Active",className:"bg-emerald-100 text-emerald-700 border-emerald-200",Icon:re},completed:{label:"Completed",className:"bg-blue-100 text-blue-700 border-blue-200",Icon:ie},paused:{label:"Paused",className:"bg-amber-100 text-amber-700 border-amber-200",Icon:V},draft:{label:"Draft",className:"bg-slate-100 text-slate-600 border-slate-200",Icon:C},cancelled:{label:"Cancelled",className:"bg-red-100 text-red-700 border-red-200",Icon:z}},c=n[s]??n.draft;return e.jsxs(w,{variant:"outline",className:`text-xs font-medium gap-1 ${c.className}`,children:[e.jsx(c.Icon,{className:"w-3 h-3"}),c.label]})}function oe({pdfStatus:s}){return!s||s==="failed"?null:s==="generating"?e.jsx(w,{variant:"outline",className:"text-xs bg-amber-50 text-amber-600 border-amber-200 animate-pulse",children:"Generating PDF…"}):s==="ready"?e.jsxs(w,{variant:"outline",className:"text-xs bg-emerald-50 text-emerald-700 border-emerald-200",children:[e.jsx(R,{className:"w-3 h-3 mr-1"}),"PDF Ready"]}):null}function ce({campaign:s,open:n,onClose:c}){const{toast:d}=q(),[l,x]=g.useState(""),[i,f]=g.useState([]),[j,N]=g.useState(""),m=H({mutationFn:async()=>(await O("POST",`/api/mrr/library/${s.id}/distribute`,{recipients:i,note:j.trim()||void 0})).json(),onSuccess:a=>{d({title:"Report distributed",description:`Sent to ${a.sent} of ${a.total} recipient${a.total!==1?"s":""}.`}),h()},onError:a=>{d({title:"Distribution failed",description:a.message,variant:"destructive"})}});function h(){x(""),f([]),N(""),c()}function v(){const a=l.trim().toLowerCase();if(!a)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){d({title:"Invalid email",description:`"${a}" is not a valid email address.`,variant:"destructive"});return}if(i.includes(a)){d({title:"Already added",description:`${a} is already in the list.`}),x("");return}if(i.length>=20){d({title:"Limit reached",description:"Maximum 20 recipients per distribution.",variant:"destructive"});return}f(t=>[...t,a]),x("")}function u(a){(a.key==="Enter"||a.key===",")&&(a.preventDefault(),v())}return s?e.jsx(G,{open:n,onOpenChange:a=>!a&&h(),children:e.jsxs(K,{className:"sm:max-w-lg","data-testid":"dialog-distribute",children:[e.jsxs(Q,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5 text-blue-600"}),"Distribute Report"]}),e.jsxs(Y,{children:["Recipients will receive a secure link to the full Majority Report for"," ",e.jsx("span",{className:"font-medium text-foreground",children:s.name}),"."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-sm font-medium mb-1.5 block",children:"Recipients"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{placeholder:"[email protected]",value:l,onChange:a=>x(a.target.value),onKeyDown:u,"data-testid":"input-recipient-email",className:"flex-1"}),e.jsx(o,{variant:"outline",size:"sm",onClick:v,"data-testid":"button-add-recipient",disabled:!l.trim(),children:e.jsx(X,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Press Enter or comma to add each address."}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:i.map(a=>e.jsxs(w,{variant:"secondary",className:"text-xs gap-1 pr-1","data-testid":`badge-recipient-${a}`,children:[a,e.jsx("button",{onClick:()=>f(y=>y.filter(t=>t!==a)),className:"ml-0.5 rounded-full hover:bg-muted p-0.5","data-testid":`button-remove-${a}`,children:e.jsx(J,{className:"w-3 h-3"})})]},a))})]}),e.jsxs("div",{children:[e.jsxs(k,{className:"text-sm font-medium mb-1.5 block",children:["Note ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(ee,{placeholder:"Add a personal note or context for the recipient…",value:j,onChange:a=>N(a.target.value),rows:3,"data-testid":"textarea-distribute-note"})]}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-slate-50 dark:bg-slate-900 border p-3 text-xs text-muted-foreground",children:[e.jsx(T,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-slate-400"}),e.jsx("span",{children:"Recipients receive a direct link only. No separate account is required to view the report, but access is restricted to recipients of this email."})]})]}),e.jsxs(Z,{children:[e.jsx(o,{variant:"outline",onClick:h,"data-testid":"button-cancel-distribute",children:"Cancel"}),e.jsx(o,{onClick:()=>m.mutate(),disabled:i.length===0||m.isPending,"data-testid":"button-send-distribute",children:m.isPending?"Sending…":`Send to ${i.length} recipient${i.length!==1?"s":""}`})]})]})}):null}function ve(){const[,s]=F(),{user:n,isLoading:c,isAuthenticated:d}=I(),[l,x]=g.useState(""),[i,f]=g.useState("all"),[j,N]=g.useState(null),{data:m=[],isLoading:h}=M({queryKey:["/api/mrr/library"],enabled:d});if(c)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary border-t-transparent"})});if(!d)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background px-4",children:e.jsx(E,{className:"w-full max-w-sm text-center",children:e.jsxs(B,{className:"pt-10 pb-8 space-y-4",children:[e.jsx("div",{className:"w-14 h-14 roun
1ded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center mx-auto",children:e.jsx(T,{className:"w-7 h-7 text-slate-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sign in required"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"You need to be signed in to access the Majority Report Library."})]}),e.jsx(o,{className:"w-full",onClick:()=>{window.location.href=`/api/login?returnTo=${encodeURIComponent(window.location.pathname)}`},"data-testid":"button-sign-in",children:"Sign in to continue"})]})})});const v=(n==null?void 0:n.role)==="admin",u=m.filter(t=>{const r=!l||t.name.toLowerCase().includes(l.toLowerCase())||(t.customerName??"").toLowerCase().includes(l.toLowerCase()),P=i==="all"||t.status===i;return r&&P}),a=m.reduce((t,r)=>(t[r.status]=(t[r.status]??0)+1,t),{}),y=[{key:"all",label:"All",count:m.length},{key:"active",label:"Active",count:a.active??0},{key:"completed",label:"Completed",count:a.completed??0},{key:"draft",label:"Draft",count:a.draft??0}];return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"border-b bg-card",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 py-8",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(C,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight","data-testid":"text-page-title",children:"Majority Report Library"}),v&&e.jsx(w,{variant:"outline",className:"text-xs font-semibold bg-violet-50 text-violet-700 border-violet-200",children:"Admin"})]}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-xl",children:v?"All platform campaigns with attribution data. View, download, or distribute settlement reports.":"Your campaigns with Majority Report data. View, download, or distribute settlement reports to stakeholders."})]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>s("/mrr"),"data-testid":"button-mrr-home",children:[e.jsx(S,{className:"w-4 h-4 mr-1.5"}),"MRaaS Home"]})]}),e.jsx("div",{className:"flex gap-1 mt-6 border-b -mb-px",children:y.map(t=>e.jsxs("button",{onClick:()=>f(t.key),"data-testid":`tab-status-${t.key}`,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${i===t.key?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[t.label,e.jsx("span",{className:`ml-1.5 text-xs px-1.5 py-0.5 rounded-full ${i===t.key?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:t.count})]},t.key))})]})}),e.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 py-6",children:[e.jsxs("div",{className:"relative mb-4 max-w-sm",children:[e.jsx(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(L,{placeholder:"Search campaigns…",value:l,onChange:t=>x(t.target.value),className:"pl-9","data-testid":"input-search"})]}),h?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((t,r)=>e.jsx(_,{className:"h-14 w-full rounded-lg"},r))}):u.length===0?e.jsxs("div",{className:"text-center py-20 text-muted-foreground","data-testid":"text-empty-state",children:[e.jsx(C,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"font-medium text-foreground",children:"No reports found"}),e.jsx("p",{className:"text-sm mt-1",children:l||i!=="all"?"Try clearing your filters.":"Campaigns with attribution data will appear here once activated."})]}):e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs(te,{children:[e.jsx(ae,{children:e.jsxs(D,{className:"bg-muted/40",children:[e.jsx(p,{className:"w-[35%]",children:"Campaign"}),e.jsx(p,{className:"hidden md:table-cell",children:"Type"}),e.jsx(p,{className:"hidden sm:table-cell",children:"Period"}),e.jsx(p,{children:"Status"}),e.jsx(p,{className:"hidden lg:table-cell text-right",children:"GMV"}),e.jsx(p,{className:"text-right",children:"Actions"})]})}),e.jsx(se,{children:u.map(t=>e.jsxs(D,{className:"hover:bg-muted/20","data-testid":`row-campaign-${t.id}`,children:[e.jsx(b,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm leading-tight","data-testid":`text-campaign-name-${t.id}`,children:t.name}),t.customerName&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5","data-testid":`text-customer-${t.id}`,children:t.customerName}),e.jsx("div",{className:"mt-1",children:e.jsx(oe,{pdfStatus:t.pdfStatus})})]})}),e.jsx(b,{className:"hidden md:table-cell text-sm text-muted-foreground",children:le(t.wedgeType)}),e.jsx(b,{className:"hidden sm:table-cell text-sm text-muted-foreground whitespace-nowrap",children:t.startDate||t.endDate?`${$(t.startDate)}
1 – ${$(t.endDate)}`:"—"}),e.jsx(b,{children:e.jsx(de,{status:t.status})}),e.jsx(b,{className:"hidden lg:table-cell text-right font-mono text-sm font-semibold",children:ne(t.totalRevenueCents)}),e.jsx(b,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsxs(o,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1 text-xs",onClick:()=>window.open(`/mrr/report/${t.id}`,"_blank"),"data-testid":`button-view-${t.id}`,title:"View report",children:[e.jsx(S,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"View"})]}),e.jsxs(o,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1 text-xs",onClick:()=>{if(t.pdfUrl&&t.pdfStatus==="ready")window.open(t.pdfUrl,"_blank");else{const r=window.open(`/mrr/report/${t.id}`,"_blank");r==null||r.addEventListener("load",()=>r.print())}},"data-testid":`button-download-${t.id}`,title:t.pdfStatus==="ready"?"Download PDF":"Open & print",children:[e.jsx(R,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:t.pdfStatus==="ready"?"PDF":"Print"})]}),e.jsxs(o,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1 text-xs text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>N(t),"data-testid":`button-distribute-${t.id}`,title:"Distribute via email",children:[e.jsx(A,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Send"})]})]})})]},t.id))})]})}),!h&&u.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-3 text-right",children:[u.length," campaign",u.length!==1?"s":"",i!=="all"||l?" matching filters":" total"]})]}),e.jsx(ce,{campaign:j,open:!!j,onClose:()=>N(null)})]})}export{ve 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.