PageSourceSearch

https://sendunlimitedemail.com/sue/mod-CEE8XTTx.js

js sendunlimitedemail.com collected 2026-10-05 06:24:26 UTC 16,220 bytes, 1 lines download raw bytes

1import{f as V,r as o,j as e,H as J,L as F}from"./edge-BOITG1XR.js";import{g as O}from"./mod-C1R88L9B.js";function ne(){const s=V(),[i,c]=o.useState(null),[u,v]=o.useState(!0),[l,h]=o.useState("all"),[g,p]=o.useState(""),[w,B]=o.useState(""),[k,E]=o.useState(""),[r,M]=o.useState("issued_at"),[y,I]=o.useState("desc"),[z,Y]=o.useState(25),[b,R]=o.useState(1),[j,D]=o.useState(new Set);o.useEffect(()=>{const t=O();if(!t){s("/auth/login?next=/invoices");return}fetch("/api/my/invoices",{headers:{Authorization:`Bearer ${t}`}}).then(n=>n.status===401?(s("/auth/login?next=/invoices"),null):n.json()).then(n=>{n&&(c(n),v(!1))}).catch(()=>v(!1))},[s]);const C=o.useMemo(()=>{if(!i?.data)return[];let t=[...i.data];if(l!=="all"&&(t=t.filter(n=>n.status?.toLowerCase()===l)),g.trim()){const n=g.toLowerCase();t=t.filter(a=>(a.invoice_number||"").toLowerCase().includes(n))}if(w&&(t=t.filter(n=>n.issued_at&&new Date(n.issued_at)>=new Date(w))),k){const n=new Date(k);n.setHours(23,59,59),t=t.filter(a=>a.issued_at&&new Date(a.issued_at)<=n)}return t.sort((n,a)=>{let d,x;r==="total"||r==="balance"?(d=parseFloat(n[r]||0),x=parseFloat(a[r]||0)):r==="invoice_number"?(d=n.invoice_number||"",x=a.invoice_number||""):(d=n[r]?new Date(n[r]).getTime():0,x=a[r]?new Date(a[r]).getTime():0);const m=d<x?-1:d>x?1:0;return y==="asc"?m:-m}),t},[i,l,g,w,k,r,y]),f=o.useMemo(()=>{if(!i?.data)return{all:0,unpaid:0,paid:0,cancelled:0,refunded:0};const t={all:i.data.length,unpaid:0,paid:0,cancelled:0,refunded:0,draft:0};for(const n of i.data)t[n.status?.toLowerCase()]=(t[n.status?.toLowerCase()]||0)+1;return t},[i]),T=o.useMemo(()=>{if(!i?.data)return{unpaid_total:0,paid_total:0,lifetime:0,this_year:0};const t=new Date(new Date().getFullYear(),0,1).getTime();return i.data.reduce((n,a)=>{const d=parseFloat(a.total)||0,x=parseFloat(a.balance)||0;return a.status==="Unpaid"&&(n.unpaid_total+=x),a.status==="Paid"&&(n.paid_total+=d,a.paid_at&&new Date(a.paid_at).getTime()>=t&&(n.this_year+=d)),n.lifetime+=d,n},{unpaid_total:0,paid_total:0,lifetime:0,this_year:0})},[i]),W=Math.max(1,Math.ceil(C.length/z)),_=C.slice((b-1)*z,b*z);o.useEffect(()=>{R(1)},[l,g,w,k,z]);function $(t){r===t?I(n=>n==="asc"?"desc":"asc"):(M(t),I("desc"))}function q(t){const n=new Set(j);n.has(t)?n.delete(t):n.add(t),D(n)}function X(){j.size===_.length?D(new Set):D(new Set(_.map(t=>t.id)))}async function G(){const t=O();for(const n of j){const a=i.data.find(d=>d.id===n);if(a)try{const x=await(await fetch(`/api/my/invoices/${encodeURIComponent(a.invoice_number)}/pdf`,{headers:{Authorization:`Bearer ${t}`}})).blob(),m=document.createElement("a");m.href=URL.createObjectURL(x),m.download=`${a.invoice_number}.pdf`,document.body.appendChild(m),m.click(),m.remove()}catch{}}D(new Set)}function U(){h("all"),p(""),B(""),E(""),M("issued_at"),I("desc")}if(u)return e.jsx(Z,{children:"Loading invoices…"});if(!i)return null;const H=(i.data||[]).length>0,P=l!=="all"||g||w||k;return e.jsxs(e.Fragment,{children:[e.jsxs(J,{children:[e.jsx("title",{children:"Invoices | SendUnlimitedEmail"}),e.jsx("meta",{name:"robots",content:"noindex"})]}),e.jsx("section",{style:{padding:"32px 0 24px",background:"linear-gradient(180deg, #F8FAFC 0%, white 100%)",borderBottom:"1px solid var(--sue-border)"},children:e.jsxs("div",{className:"sue-container",children:[e.jsx(F,{to:"/dashboard",style:{fontSize:13,color:"var(--sue-blue-600)",textDecoration:"none",fontWeight:600},children:"← Back to dashboard"}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",flexWrap:"wrap",gap:14,marginTop:12},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"clamp(22px, 3vw, 30px)",fontWeight:800,margin:0,letterSpacing:"-0.02em"},children:"Invoices"}),e.jsx("p",{style:{color:"var(--sue-text-muted)",margin:"4px 0 0",fontSize:14},children:"Every charge, refund, and payment in one place."})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx(F,{to:"/dashboard",className:"sue-btn sue-btn-outline sue-btn-sm",children:"Dashboard"}),e.jsx(F,{to:"/checkout?plan=professional",className:"sue-btn sue-btn-primary sue-btn-sm",children:"+ New order"})]})]})]})}),e.jsx("section",{style:{padding:"20px 0"},children:e.jsx("div",{className:"sue-container",children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[e.jsx(N,{label:"Outstanding",value:`$${T.unpaid_total.toFixed(2)}`,hint:`${f.unpaid||0} unpaid`,color:T.unpaid_total>0?"#D97706":"#16A34A"}),e.jsx(N,{label:"Paid total",value:`$${T.paid_total.toFixed(2)}`,hint:`${f.paid||0} paid`,color:"#16A34A"}),e.jsx(N,{label:"This year",value:`$${T.this_year.toFixed(2)}`,hint:new Date().getFullYear(),color:"#0066CC"}),e.jsx(N,{label:"Lifetime billed",value:`$${T.lifetime.toFixed(2)}`,hint:`${f.all} invoices`,color:"#7C3AED"})]})})}),!H&&!P&&e.jsx("section",{style:{padding:"24px 0 64px"},children:e.jsx("div",{className:"sue-container",children:e.jsxs("div",{style:{background:"linear-gradient(135deg, white, color-mix(in srgb, var(--sue-blue-600) 4%, white))",border:"1px dashed var(--sue-blue-300)",borderRadius:"var(--sue-r-xl)",padding:"48px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:56,height:56,borderRadius:"50%",background:"linear-gradient(135deg, var(--sue-blue-600), var(--sue-teal-600))",display:"inline-grid",placeItems:"center",marginBottom:14,color:"white"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsx("h3",{style:{fontSize:18,fontWeight:800,marginBottom:8},children:"No invoices yet"}),e.jsx("p",{style:{color:"var(--sue-text-muted)",maxWidth:460,margin:"0 auto 16px"},children:"Once you place your first order, the invoice appears here. Every recurring renewal is also stored as its own invoice — fully accessible, downloadable as PDF."}),e.jsx(F,{to:"/pricing",className:"sue-btn sue-btn-primary",children:"View plans →"})]})})}),(H||P)&&e.jsx("section",{style:{padding:"12px 0 64px"},children:e.jsxs("div",{className:"sue-container",children:[e.jsxs("div",{style:{background:"white",border:"1px solid var(--sue-border)",borderRadius:"var(--sue-r-lg)",padding:12,marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:12},children:[[["all","All",f.all],["unpaid","Unpaid",f.unpaid||0],["paid","Paid",f.paid||0],["cancelled","Cancelled",f.cancelled||0],["refunded","Refunded",f.refunded||0]].map(([t,n,a])=>e.jsxs("button",{type:"button",onClick:()=>h(t),style:{padding:"6px 14px",borderRadius:999,fontSize:12.5,fontWeight:600,background:l===t?"var(--sue-blue-600)":"var(--sue-bg-muted)",color:l===t?"white":"var(--sue-text-muted)",border:`1px solid ${l===t?"var(--sue-blue-600)":"var(--sue-border)"}`,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[n," ",e.jsx("span",{style:{background:l===t?"rgba(255,255,255,0.25)":"white",padding:"1px 7px",borderRadius:999,fontSize:11},children:a})]},t)),P&&e.jsx("button",{type:"button",onClick:U,style:{marginLeft:"auto",fontSize:12,color:"var(--sue-text-muted)",border:"none",background:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear filters"})]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[e.jsx("input",{value:g,onChange:t=>p(t.target.value),placeholder:"Search invoice #…",style:{padding:"7px 12px",fontSize:13,border:"1px solid var(--sue-border)",borderRadius:6,minWidth:180,flex:"1 1 200px"}}),e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center",fontSize:12.5,color:"var(--sue-text-muted)"},children:[e.jsx("span",{children:"From"}),e.jsx("input",{type:"date",value:w,onChange:t=>B(t.target.value),style:L}),e.jsx("span",{children:"to"}),e.jsx("input",{type:"date",value:k,onChange:t=>E(t.target.value),style:L})]}),e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center",fontSize:12.5,color:"var(--sue-text-muted)"},children:[e.jsx("span",{children:"Per page"}),e.jsx("select",{value:z,onChange:t=>Y(parseInt(t.target.value)),style:L,children:[10,25,50,100].map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),j.size>0&&e.jsxs("div",{style:{marginTop:10,padding:10,background:"var(--sue-blue-50, #EBF4FF)",border:"1px solid #BFDBFE",borderRadius:8,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:13.5},children:[e.jsxs("span",{children:[e.jsx("strong",{children:j.size})," selected"]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:G,className:"sue-btn sue-btn-outline sue-btn-sm",children:"⬇ Download PDFs"}),e.jsx("button",{type:"button",onClick:()=>D(new Set),className:"sue-btn sue-btn-ghost sue-btn-sm",children:"Clear"})]})]})]}),C.length===0?e.jsxs("div",{style:{background:"white",border:"1px dashed var(--sue-border)",borderRadius:"var(--sue-r-lg)",padding:40,textAlign:"center",color:"var(--sue-text-muted)"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--sue-text)"},children:"No invoices match these filters"}),e.jsx("div",{style:{fontSize:13,marginTop:6},children:"Try clearing filters or expand the date range."}),P&&e.jsx("button",{type:"button",onClick:U,className:"sue-btn sue-btn-outline sue-btn-sm",style:{marginTop:14},children:"Clear filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{background:"white",border:"1px solid var(--sue-border)",borderRadius:"var(--sue-r-lg)",overflow:"hidden"},children:e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:14},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"var(--sue-bg-muted)"},children:[e.jsx("th",{style:{width:40,padding:"11px 16px"},children:e.jsx("input",{type:"checkbox",checked:j.size===_.length&&_.length>0,onChange:X})}),e.jsx(A,{col:"invoice_number",label:"Invoice #",sortBy:r,sortDir:y,onClick:$}),e.jsx(Q,{children:"Status"}),e.jsx(A,{col:"total",label:"Total",align:"right",sortBy:r,sortDir:y,onClick:$}),e.jsx(A,{col:"balance",label:"Balance",align:"right",sortBy:r,sortDir:y,onClick:$}),e.jsx(A,{col:"issued_at",label:"Issued",sortBy:r,sortDir:y,onClick:$}),e.jsx(A,{col:"due_at",label:"Due",sortBy:r,sortDir:y,onClick:$}),e.jsx("th",{style:{width:130}})]})}),e.jsx("tbody",{children:_.map(t=>e.jsx(K,{i:t,selected:j.has(t.id),onSelect:()=>
1q(t.id)},t.id))}),e.jsx("tfoot",{children:e.jsxs("tr",{style:{background:"var(--sue-bg-muted)",borderTop:"2px solid var(--sue-border)"},children:[e.jsxs("td",{colSpan:"3",style:{padding:"12px 16px",fontWeight:700,fontSize:12.5,color:"var(--sue-text-muted)",textTransform:"uppercase",letterSpacing:"0.04em"},children:["Showing ",_.length," of ",C.length]}),e.jsxs("td",{style:{padding:"12px 16px",textAlign:"right",fontFamily:"monospace",fontWeight:700},children:["$",C.reduce((t,n)=>t+parseFloat(n.total||0),0).toFixed(2)]}),e.jsxs("td",{style:{padding:"12px 16px",textAlign:"right",fontFamily:"monospace",fontWeight:700,color:"#D97706"},children:["$",C.reduce((t,n)=>t+parseFloat(n.balance||0),0).toFixed(2)]}),e.jsx("td",{colSpan:"3"})]})})]})})}),W>1&&e.jsxs("div",{style:{marginTop:14,display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:8},children:[e.jsxs("div",{style:{fontSize:13,color:"var(--sue-text-muted)"},children:["Page ",e.jsx("strong",{children:b})," of ",W]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{disabled:b===1,type:"button",onClick:()=>R(t=>Math.max(1,t-1)),className:"sue-btn sue-btn-outline sue-btn-sm",children:"← Prev"}),Array.from({length:Math.min(W,7)}).map((t,n)=>{const a=n+1;return e.jsx("button",{type:"button",onClick:()=>R(a),style:{padding:"6px 12px",borderRadius:6,fontSize:12.5,fontWeight:600,background:b===a?"var(--sue-blue-600)":"white",color:b===a?"white":"var(--sue-text-muted)",border:`1px solid ${b===a?"var(--sue-blue-600)":"var(--sue-border)"}`,cursor:"pointer"},children:a},a)}),e.jsx("button",{disabled:b===W,type:"button",onClick:()=>R(t=>Math.min(W,t+1)),className:"sue-btn sue-btn-outline sue-btn-sm",children:"Next →"})]})]})]})]})})]})}function K({i:s,selected:i,onSelect:c}){const u=V(),v=s.status==="Unpaid",l=`/invoice/${s.invoice_number||s.id}`,h=parseFloat(s.balance)||0,g=parseFloat(s.total)||0;return e.jsxs("tr",{style:{borderTop:"1px solid var(--sue-border)",cursor:"pointer",transition:"background 0.12s"},onClick:()=>u(l),onMouseEnter:p=>p.currentTarget.style.background="var(--sue-bg-muted)",onMouseLeave:p=>p.currentTarget.style.background="transparent",children:[e.jsx("td",{onClick:p=>p.stopPropagation(),style:{padding:"12px 16px"},children:e.jsx("input",{type:"checkbox",checked:i,onChange:c})}),e.jsxs(S,{mono:!0,children:[e.jsx("span",{style:{fontWeight:700},children:s.invoice_number}),v&&e.jsx("div",{style:{fontFamily:"inherit",fontWeight:600,fontSize:10.5,color:"#D97706",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:2},children:"Payment due"})]}),e.jsx(S,{children:e.jsxs("span",{style:{fontSize:11,fontWeight:700,padding:"3px 9px",borderRadius:999,background:`color-mix(in srgb, ${s.status_color} 14%, white)`,color:s.status_color,border:`1px solid color-mix(in srgb, ${s.status_color} 35%, transparent)`,textTransform:"uppercase",letterSpacing:"0.04em"},children:[s.status,s.is_overdue?" · OVERDUE":""]})}),e.jsxs(S,{align:"right",mono:!0,children:["$",g.toFixed(2)]}),e.jsx(S,{align:"right",mono:!0,children:e.jsxs("span",{style:{color:h>0?"#D97706":"#16A34A",fontWeight:700},children:["$",h.toFixed(2)]})}),e.jsx(S,{children:e.jsx("span",{style:{fontSize:12.5,color:"var(--sue-text-muted)"},children:s.issued_at?new Date(s.issued_at).toLocaleDateString():"—"})}),e.jsx(S,{children:e.jsx("span",{style:{fontSize:12.5,color:s.is_overdue?"#B91C1C":"var(--sue-text-muted)",fontWeight:s.is_overdue?700:400},children:s.due_at?new Date(s.due_at).toLocaleDateString():"—"})}),e.jsx(S,{align:"right",onClick:p=>p.stopPropagation(),children:v?e.jsx(F,{to:l,className:"sue-btn sue-btn-sm",style:{background:"#D97706",color:"white",borderColor:"#D97706",fontSize:12},children:"Pay now →"}):e.jsx(F,{to:l,style:{color:"var(--sue-blue-600)",fontSize:13,fontWeight:600,textDecoration:"none"},children:"View →"})})]})}function N({label:s,value:i,hint:c,color:u}){return e.jsxs("div",{style:{background:"white",border:"1px solid var(--sue-border)",borderRadius:"var(--sue-r-lg)",padding:"14px 16px",position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${u}, color-mix(in srgb, ${u} 60%, white))`}}),e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--sue-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em"},children:s}),e.jsx("div",{style:{fontSize:22,fontWeight:800,color:u,marginTop:4,letterSpacing:"-0.02em"},children:i}),c!=null&&e.jsx("div",{style:{fontSize:12,color:"var(--sue-text-subtle)",marginTop:2},children:c})]})}function A({col:s,label:i,sortBy:c,sortDir:u,onClick:v,align:l}){const h=c===s;return e.jsxs("th",{onClick:()=>v(s),style:{textAlign:l||"left",padding:"11px 16px",fontSize:11.5,fontWeight:700,color:h?"var(--sue-blue-600)":"var(--sue-text-muted)",letterSpacing:"0.06em",textTransform:"uppercase",cursor:"pointer",userSelect:"none"},children:[i," ",h&&e.jsx("span",{style:{fontSize:9},children:u==="asc"?"▲":"▼"})]})}function Q({children:s,align:i}){return e.jsx("th",{style:{textAlign:i||"left",padding:"11px 16px",fontSize:11.5,fontWeight:700,color:"var(--sue-text-muted)",letterSpacing:"0.06em",textTransform:"uppercase"},children:s})}function S({children:s,align:i,mono:c,style:u}){return e.jsx("td",{style:{padding:"12px 16px",textAlign:i||"left",fontFamily:c?"monospace":"inherit",fontWeight:c?600:400,...u},children:s})}function Z({children:s}){return e.jsx("section",{style:{minHeight:"60vh",display:"grid",placeItems:"center"},children:e.jsx("div",{style:{color:"var(--sue-text-muted)"},children:s})})}const L={padding:"6px 8px",fontSize:12.5,border:"1px solid var(--sue-border)",borderRadius:6};export{ne 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.