1import{y as E,r as g,j as e,a as c,v as O}from"./react-DZIhD4CV.js";import{cJ as F,b_ as A,bT as U,bU as T,bX as y,bV as B,bZ as k,c as p,c7 as R,cK as $,at as _,cL as x,cM as v,cx as w,c3 as N,c6 as Q,c4 as W,bW as M,cN as V,a7 as H,ag as z,cO as K,bl as G}from"./index-DYHSnDuC.js";import{BillingLoader as Y,BillingError as q}from"./BillingLayout-B5dAE5ld.js";import{I as o,g as J,b as X,c as Z,d as tt,p as et}from"./billing-DM3WdHI1.js";import{D as u}from"./constants-D1Rvb1JH.js";import"./d3-q0zOtUjj.js";import"./partners-B0O1S0Gm.js";import"./ErrorCard-Df5f0Dce.js";const nt=c.div(["text-align:center;border-bottom:1px solid ",";padding:10px;"],p.gray10),st=c.div(["color:",";display:flex;align-items:center;"],p.red70),at=c(M)(["height:60px;"]),D=c(_)(["display:inline-flex !important;text-decoration:underline;color:",";&:hover{color:",";}&:active{color:",";}"],p.red70,p.red70,p.red70),rt="date",it="desc",ot=[o.OPEN,o.PAID,o.LATE,o.DELINQUENT,o.ACTION_REQUIRED],lt=[{text:"date",name:"date"},{text:"description",name:"description",ratio:2},{text:"status",name:"status"},{text:"amount",name:"amount"}],ct=["date","status","amount"],C=15,P=(t,n,s)=>k(t,n==="date"?r=>new Date(r.billingCycleStart):r=>n==="status"?r.state:r.total,s||"desc"),dt=(t,n)=>{const s=(n-1)*C,a=s+C;return t.slice(s,a)},yt=async t=>{const[,n]=t.id.split("-"),s=await X(n),a=new Blob(["\uFEFF",s]),r=URL.createObjectURL(a),i=`Mux_invoice_${new Date(t.billingCycleStart).toISOString().split("T")[0]}.csv`;return w(r,i),null},ut=async t=>{const[,n]=t.id.split("-"),{data:{url:s}}=await J(n),a=`Mux_invoice_${new Date(t.billingCycleStart).toISOString().split("T")[0]}.pdf`;return w(s,a),null},b=async t=>{const[,n]=t.id.split("-"),{data:{url:s}}=await Z(n);return window.open(s,"_blank"),null},pt=(t,n)=>{let s,a;return t.lastBillingCycleStart?(s=t.lastBillingCycleStart,a=t.billingCycleStart):(s=t.billingCycleStart,a=t.billingCycleEnd),`${n(s,u.mm_dd_yyyy)} - ${n(a,u.mm_dd_yyyy)}`},mt=({invoices:t,setMyInvoices:n,sortingColumn:s,sortingOrder:a})=>{const r=E(),[i,l]=g.useState(s),[f,h]=g.useState(a);return e.jsxs(U,{children:[lt.map(d=>e.jsx(T,{sortable:ct.includes(d.name),sortDirection:i===d.name?f:void 0,onSort:(j,I)=>{let m="asc";(I==="asc"||I===void 0)&&(m="desc");const L=P(t,j,m);n(L),h(m),l(j),r({search:`sort_by=${j}&order_direction=${m}`})},columnName:d.name,ratio:d.ratio??1,children:d.text},`head-${d.name}`)),e.jsx(T,{children:e.jsx(y,{})})]})},S=({caption:t,status:n})=>e.jsxs(st,{children:[e.jsx(bt,{children:e.jsxs(N,{children:[e.jsx(Q,{side:"bottom",children:t}),e.jsx(W,{asChild:!0,children:e.jsx(x,{tabIndex:0})})]})}),e.jsx(St,{children:v(n,!1)})]}),xt=({status:t,invoice:n})=>{const s=R();if(t===o.DELINQUENT)return n.stripeInvoiceUrl?e.jsxs(D,{onClick:()=>b(n),rel:"noopener noreferrer","data-analytics-selector":"invoices-retry-payment",children:[e.jsx(x,{})," Retry payment"]}):e.jsx(S,{caption:"This payment is past due. Please contact your account representative.",status:t});if(t===o.LATE){if(!n.stripeInvoiceUrl){const r=`We will automatically retry this payment on ${s(new Date(n.date||Date.now()),u.mm_dd_yyyy)}.`;return e.jsx(S,{caption:r,status:"Payment failed"})}return e.jsxs(D,{onClick:()=>b(n),rel:"noopener noreferrer","data-analytics-selector":"invoices-retry-payment",children:[e.jsx(x,{})," Retry payment"]})}if(t===o.PAID){const a=s(new Date(n.date||Date.now()),u.mm_dd_yyyy);return e.jsxs("div",{children:[v(t,!1)," ",a]})}if(t===o.ACTION_REQUIRED){if(!n.stripeInvoiceUrl){const r=`We will automatically retry this payment on ${s(new Date(n.date||Date.now()),u.mm_dd_yyyy)}.`;return e.jsx(S,{caption:r,status:"Payment failed"})}return e.jsxs(D,{onClick:()=>b(n),rel:"noopener noreferrer","data-analytics-selector":"invoices-retry-payment-3ds",children:[e.jsx(x,{})," Retry payment"]})}return e.jsx("div",{children:v(t,!1)})},gt=({invoice:t})=>{const n=R();return e.jsxs(at,{children:[e.jsx(y,{left:!0,children:n(new Date(t.billingCycleStart),u.mm_dd_yyyy)}),e.jsxs(y,{ratio:2,children:["Billing cycle ",pt(t,n)]}),e.jsx(y,{children:e.jsx(xt,{status:t.state,invoice:t})}),e.jsx(y,{right:!0,children:$.format(t.total/100)}),e.jsxs(y,{right:!0,children:[e.jsx(_,{as:"button",variant:"primary",onClick:()=>ut(t),"aria-label":"link pdf",children:"PDF"}),e.jsx("span",{children:"Â |Â "}),e.jsx(_,{as:"button",variant:"primary",onClick:()=>yt(t),children:"CSV"})]})]})}
1,ft=({invoices:t})=>!t||t.length===0?e.jsx(nt,{children:"You don't have any invoices yet."}):e.jsx(B,{children:t.map(n=>e.jsx(gt,{invoice:n},`row-${n.id}`))}),ht=(t,n,s)=>{const a=t.filter(r=>ot.includes(r.state));return P(a,n,s)},jt=({invoices:t})=>{const n=E(),{sort_by:s=rt,order_direction:a=it,page:r=1}=F(),[i,l]=g.useState(ht(t,s,a));return g.useEffect(()=>{l(i)},[l,i]),e.jsxs(A,{bordered:!0,children:[e.jsx(mt,{invoices:i,setMyInvoices:l,sortingColumn:s,sortingOrder:a}),e.jsx(ft,{invoices:dt(i,r)}),i.length>0&&e.jsx(Dt,{page:r,perPage:C,total:i.length,label:["invoice","invoices"],linkProps:({page:f})=>({onClick:h=>{h.preventDefault(),n({search:`page=${f}`})}})})]})};var Dt=c(V)(["margin:20px;"]),bt=c("span")(["padding-top:3px;"]),St=c("span")(["margin-left:5px;"]);const _t=()=>{const{isFetching:t,error:n,data:s}=tt(),a=H(),r=O(),i=z();return K(`billing:${a}`,({type:l})=>{l==="update_invoices"&&(r.invalidateQueries({queryKey:et(a)}),i({id:"invoices_updated",type:"Success",title:"Success!",description:"We have received your payment"}))}),t?e.jsx(Y,{}):n||!s?e.jsx(q,{}):e.jsx(jt,{invoices:s?.invoices})};function Lt(){return G("Invoices | Billing"),e.jsx(_t,{})}export{Lt as default}; 2//# sourceMappingURL=InvoicesRoute-BKaCznDD.js.map
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.