PageSourceSearch

https://app.backstagebaton.com/app/assets/AccountPaymentsPage-B1CtqQzU.js

js backstagebaton.com collected 2026-10-07 08:49:47 UTC 12,249 bytes, 1 lines download raw bytes

1import{g as ie,b as oe,c as G,e as le,r,z as de,t as ce,j as s,B as d,G as c,S as K,I as ue,d as me,M as he}from"./index-_aijvlUq.js";import{P as pe}from"./PageHeader-DCofr6qo.js";import{I as j}from"./Input-ysTyZFq5.js";import{a as xe}from"./Skeleton-B3Wj6cNd.js";import{E as Y}from"./EmptyState-CPGKooqj.js";import{p as x}from"./payments-BcDSbBQ_.js";const ye=.029,ge=30,be=.008,W=500;function fe(o,u){if(!Number.isInteger(o)||o<0)return null;if(o===0)return 0;if(u==="card")return Math.ceil((o+ge)/(1-ye));if(u==="ach"){const i=Math.ceil(o/(1-be));return i-o>W?o+W:i}return null}function je(o,u){const i=fe(o,u);return i==null?null:i-o}const Q={owed:{text:"Due",cls:"bg-amber-100 text-amber-700"},processing:{text:"Processing",cls:"bg-blue-100 text-blue-700"},paid:{text:"Paid",cls:"bg-green-100 text-green-700"},waived:{text:"Waived",cls:"bg-gray-100 text-gray-500"}};function Ne({status:o}){const u=Q[o]||Q.owed;return s.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${u.cls}`,children:u.text})}function ze(){const o=ie();oe(e=>e.user);const u=G(e=>e.showSuccess),i=G(e=>e.showError),[V,J]=le(),[l,F]=r.useState(null),[X,Z]=r.useState(!0),[ee,M]=r.useState(!1),[N,E]=r.useState(null),[t,v]=r.useState(null),[g,L]=r.useState(""),[m,D]=r.useState(""),[w,I]=r.useState("1"),k=t?.sizes?Math.max(1,parseInt(w,10)||0):1,b=(t?.priceCents||0)*k,B=e=>t?.surcharges&&je(b,e)||0,[C,$]=r.useState(!1),[U,se]=r.useState(""),[te,_]=r.useState(!1),[S,ae]=r.useState({}),[P,ne]=r.useState(null),[O,R]=r.useState(""),y=r.useCallback(async()=>{M(!1);try{const e=await x.getMyPayments();F(e),(e?.charges||[]).length>0&&x.statements.getMine().then(a=>{ne(a),R(n=>n||a?.season?.key||"")}).catch(de("my statement: no charges to put on one"))}catch(e){e?.code==="FEATURE_NOT_AVAILABLE"?F({onlinePaymentsEnabled:!1,charges:[],products:[]}):(M(!0),i(ce("your payments")))}finally{Z(!1)}},[]);r.useEffect(()=>{const e=V.get("payment");if(e&&(J({},{replace:!0}),e==="success"&&u("Payment submitted — bank transfers can take a few days to clear.")),y(),e==="success"){const a=setTimeout(y,4e3),n=setTimeout(y,12e3);return()=>{clearTimeout(a),clearTimeout(n)}}},[]);async function z(e,a){E(e.id);try{const n=parseFloat(S[e.id]),h=await x.createMyCheckout({chargeId:e.id,...a?{rail:a}:{}
1,...Number.isFinite(n)&&n>=1?{donationCents:Math.round(n*100)}:{}});window.location.assign(h.url)}catch(n){i(n.message||"Couldn’t start the payment. Try again."),E(null)}}async function A(e,a){try{await x.promiseCharge(e.id,a),u(a==="check"&&l?.checkPayableTo?`Got it — make your check payable to ${l.checkPayableTo}.`:a?`Got it — bring your ${a} to your treasurer.`:"Promise cleared."),await y()}catch(n){i(n.message||"Couldn’t save that.")}}async function T(e){if(t.requiresNote&&!g.trim())return i(t.noteLabel?`Please provide: ${t.noteLabel}`:"Please fill in the details first.");if(t.sizes&&!m)return i("Pick a size first.");const a=t.sizes?.find(h=>h.id===m)?.inStock??null,n=parseInt(w,10)||0;if(t.sizes&&(n<1||a!=null&&n>a))return i(`Choose between 1 and ${a}.`);$(!0);try{const h=await x.createMyPurchase({productId:t.id,...m?{equipmentId:m,quantity:n}:{},...g.trim()?{note:g.trim()}:{},...e?{rail:e}:{}});window.location.assign(h.url)}catch(h){i(h.message||"Couldn’t start the purchase."),$(!1)}}async function re(e){e.preventDefault();const a=parseFloat(U);if(!Number.isFinite(a)||a<1)return i("Enter a donation amount of at least $1.");_(!0);try{const n=(l?.donationFunds||[])[0],h=await x.createMyDonation({amountCents:Math.round(a*100),...n?{productId:n.id}:{}});window.location.assign(h.url)}catch(n){i(n.message||"Couldn’t start the donation."),_(!1)}}const H=(l?.charges||[]).filter(e=>e.status==="owed"&&e.productType!=="donation"||e.status==="processing"),q=(l?.charges||[]).filter(e=>e.status==="paid"),p=l?.onlinePaymentsEnabled,f=l?.taxExempt?"Dues aren't tax-deductible, but donations above your dues may be — you'll receive a year-end donation statement for your tax records.":null;return s.jsxs("div",{className:"px-4 pt-3 md:px-0 md:pt-0",children:[!o&&s.jsx(pe,{title:"Dues & Payments",subtitle:"What you owe, ways to pay, and your payment history."}),X?s.jsx(xe,{}):s.jsxs("div",{className:"space-y-4",children:[ee?s.jsx(Y,{title:"Couldn't load your payments.",description:"Refresh to try again.",action:s.jsx(d,{variant:"secondary",size:"md",onClick:y,children:"Try again"})}):H.length===0?s.jsx(Y,{variant:"success",title:"You're all paid up!",description:"Nothing owing right now."}):H.map(e=>s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"font-medium text-gray-900",children:[e.productName,e.periodKey?s.jsxs("span",{className:"text-gray-400",children:[" · ",e.periodKey]}):null]}),s.jsx("p",{className:"text-2xl font-bold text-gray-900 mt-1",children:c(e.amountCents)})]}),s.jsx(Ne,{status:e.status})]}),e.status==="processing"?s.jsx("p",{className:"text-sm text-gray-500 mt-3",children:"Your bank transfer is in progress — nothing more to do. It typically clears within a few business days."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[p&&(e.surcharges?s.jsxs(s.Fragment,{children:[s.jsxs(d,{variant:"primary",size:"md",isLoading:N===e.id,onClick:()=>z(e,"ach"),children:["Bank transfer · ",c(e.amountCents+e.surcharges.ach)]}),s.jsxs(d,{variant:"secondary",size:"md",disabled:N===e.id,onClick:()=>z(e,"card"),children:["Card · ",c(e.amountCents+e.surcharges.card)]})]}):s.jsxs(d,{variant:"primary",size:"md",isLoading:N===e.id,onClick:()=>z(e),children:["Pay ",c(e.amountCents)," online"]})),e.promisedMethod?s.jsxs(d,{variant:"ghost",size:"md",onClick:()=>A(e,null),children:['Cancel "',e.promisedMethod,'" plan']}):s.jsxs(s.Fragment,{children:[s.jsx(d,{variant:"secondary",size:"md",onClick:()=>A(e,"check"),children:"I'll bring a check"}),s.jsx(d,{variant:"secondary",size:"md",onClick:()=>A(e,"cash"),children:"I'll bring cash"})]})]}),p&&s.jsx("p",{className:"text-xs text-gray-400 mt-2",children:"Apple Pay and Google Pay are offered automatically at checkout on supported devices (card rate applies)."}),p&&s.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[s.jsx("label",{className:"text-sm text-gray-500",htmlFor:`add
1on-${e.id}`,children:"Add a donation (optional)"}),s.jsx("div",{className:"w-24",children:s.jsx(j,{id:`addon-${e.id}`,type:"number",min:"1",step:"1",placeholder:"$",value:S[e.id]||"",onChange:a=>ae(n=>({...n,[e.id]:a.target.value}))})}),parseFloat(S[e.id])>=1&&s.jsx("span",{className:"text-xs text-gray-400",children:"one payment, recorded separately as a donation"})]}),p&&f&&e.productType==="dues"&&s.jsx("p",{className:"text-xs text-gray-400 mt-1.5",children:f}),e.surcharges&&p&&s.jsx("p",{className:"text-xs text-gray-400 mt-2",children:"Online prices include the payment processor's fee. Cash and check have no fee."}),e.promisedMethod&&s.jsxs("p",{className:"text-sm text-gray-500 mt-2",children:["You said you'd pay by ",e.promisedMethod,".",e.promisedMethod==="check"&&l?.checkPayableTo&&s.jsxs(s.Fragment,{children:[" Make it payable to ",s.jsx("span",{className:"font-medium text-gray-700",children:l.checkPayableTo}),"."]})," ",l?.checkInstructions||"Hand it to your treasurer whenever works."]})]})]},e.id)),p&&(l?.products||[]).length>0&&s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-3",children:"Available from Your Organization"}),s.jsx("ul",{className:"divide-y divide-gray-100",children:l.products.map(e=>s.jsxs("li",{className:"py-3 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"font-medium text-gray-900",children:e.name}),e.description&&s.jsx("p",{className:"text-sm text-gray-500",children:e.description})]}),s.jsxs(d,{variant:"secondary",size:"sm",onClick:()=>{v(e),L(""),D(""),I("1")},children:["Buy · ",c(e.priceCents),"…"]})]},e.id))})]}),p&&s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Support the Band"}),s.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:["Donations are separate from dues",l?.checkPayableTo?s.jsxs(s.Fragment,{children:[" — or write a bigger check payable to ",s.jsx("span",{className:"font-medium text-gray-700",children:l.checkPayableTo})," and your treasurer will record the extra as a donation"]}):null,".",f&&s.jsxs(s.Fragment,{children:[" ",f]})]}),s.jsxs("form",{onSubmit:re,className:"flex flex-wrap items-end gap-2",children:[s.jsx("div",{className:"w-32",children:s.jsx(j,{label:"Amount (USD)",type:"number",min:"1",step:"1",value:U,onChange:e=>se(e.target.value),placeholder:"25"})}),s.jsx(d,{type:"submit",variant:"primary",size:"md",isLoading:te,children:"Give online"})]})]}),P&&s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Statement"}),s.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"What you were charged and paid, and any balance, for one season. Dues and fees are not tax-deductible; donations are listed separately."}),s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[(P.seasons||[]).length>1&&s.jsx("div",{className:"w-40",children:s.jsx(K,{label:"Season",value:O,onChange:e=>R(e.target.value),options:P.seasons.map(e=>({value:e.key,label:e.label}))})}),s.jsx(d,{variant:"ghost",size:"md",onClick:()=>ue(x.statements.myPrintUrl({season:O||void 0})),children:"Print my statement"})]})]}),q.length>0&&s.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[s.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-3",children:"Payment History"}),s.jsx("ul",{className:"divide-y divide-gray-100",children:q.map(e=>s.jsxs("li",{className:"py-2.5 flex items-center justify-between gap-3 text-sm",children:[s.jsxs("span",{className:"text-gray-700",children:[e.productName,e.periodKey?s.jsxs("span",{className:"text-gray-400",children:[" · ",e.periodKey]}):null]}),s.jsxs("span",{className:"text-gray-500",children:[e.paidAt?me(String(e.paidAt).slice(0,10)):""," · ",s.jsx("span",{className:"font-medium text-gray-900",children:c(e.amountCents)})]})]},e.id))})]})]}),s.jsx(he,{isOpen:!!t,onClose:()=>v(null),title:t?`Buy ${t.name}`:"",size:"sm",children:t&&s.jsxs("div",{className:"space-y-4",children:[(t.sizes?.find(e=>e.id===m)?.photoUrl||t.photoUrl)&&s.jsx("img",{src:t.sizes?.find(e=>e.id===m)?.photoUrl||t.photoUrl,alt:"",className:"w-full max-h-48 object-contain rounded-lg border border-gray-200 bg-gray-50"}),s.jsxs("p",{className:"text-sm text-gray-600",children:[k>1?s.jsxs(s.Fragment,{children:[c(t.priceCents)," each · ",k," = ",s.jsx("span",{className:"font-semibold text-gray-900",children:c(b)})]}):c(t.priceCents),t.description?` — ${t.description}`:""]}),t.sizes&&s.jsx(K,{label:"Size",value:m,onChange:e=>D(e.target.value),placeholder:"Pick a size…",options:t.sizes.map(e=>({value:e.id,label:e.label}))}),t.sizes&&m&&s.jsx(j,{label:"How many",type:"number",min:1,max:t.sizes.find(e=>
1e.id===m)?.inStock||1,inputMode:"numeric",value:w,onChange:e=>I(e.target.value)}),t.requiresNote&&s.jsx(j,{label:t.noteLabel||"Details",value:g,onChange:e=>L(e.target.value),placeholder:t.noteLabel||""}),s.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[t.surcharges?s.jsxs(s.Fragment,{children:[s.jsxs(d,{type:"button",variant:"primary",size:"md",isLoading:C,onClick:()=>T("ach"),children:["Bank transfer · ",c(b+B("ach"))]}),s.jsxs(d,{type:"button",variant:"secondary",size:"md",disabled:C,onClick:()=>T("card"),children:["Card · ",c(b+B("card"))]})]}):s.jsx(d,{type:"button",variant:"primary",size:"md",isLoading:C,onClick:()=>T(),children:"Continue to payment"}),s.jsx(d,{type:"button",variant:"ghost",size:"md",onClick:()=>v(null),children:"Cancel"})]})]})})]})}export{ze as AccountPaymentsPage};

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.