PageSourceSearch

https://mirlo.space/assets/Index-Bp8mlhB7.js

js mirlo.space collected 2026-10-02 03:33:37 UTC 7,021 bytes, 2 lines download raw bytes

1import{u as G,v as g,R as r,j as s}from"./vendor-DxTwiIr9.js";import{aj as X,aZ as ee,a_ as se,a$ as te,b0 as ae,ak as ne,d as $,y as ie,o as H,B as y,b1 as le,b2 as re,b3 as ce,b4 as oe,b5 as de}from"./index-B0cS9kiR.js";import{M as me}from"./ManageSectionWrapper-w_EmI7Iz.js";import"./charts-DHrntohF.js";import"./i18n-BmyL0TSe.js";import"./markdown-CNkDHZ-E.js";import"./editor-Cm2fdcmq.js";import"./player-Dfxbckx2.js";const ue="pk_live_51Mqk7sLg9Wvtcfb9V94fKToU4k4uWxyp6N3HqtOPd5xhvb3ubHIRyA2LyFvHVTdmSc5pJ9IL0rG9Kzf3DbrUQiel00QeWKDimZ",k=(i,t)=>"".concat(((i!=null?i:0)/100).toFixed(2)," ").concat((t!=null?t:"usd").toUpperCase()),pe=i=>new Promise(t=>setTimeout(t,i)),he=({onDone:i})=>{const t=ce(),n=oe(),[c,o]=r.useState(!1),h=async()=>{var x,d;if(!t||!n)return;o(!0);const{error:p,paymentIntent:b}=await t.confirmPayment({elements:n,confirmParams:{return_url:window.location.href},redirect:"if_required"});o(!1),i(p?"error: ".concat((x=p.message)!=null?x:"payment failed"):(d=b==null?void 0:b.status)!=null?d:"submitted")};return s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx(de,{options:{layout:"accordion"}}),s.jsx(y,{onClick:h,isLoading:c,disabled:!t||!n,children:"Confirm online payment"})]})},xe=({clientSecret:i,stripeAccountId:t,onDone:n})=>{const[c,o]=r.useState(null);return r.useEffect(()=>{le(ue,{stripeAccount:t}).then(o)},[t]),c?s.jsx(re,{stripe:c,options:{clientSecret:i},children:s.jsx(he,{onDone:n})}):null},Ne=()=>{var U,F,O,_,z,W,K,B,D;const{artistId:i}=G(),t=Number(i),{data:n}=g(X(t)),{data:c}=g(ee({artistId:t})),{data:o}=g(se({artistId:t})),{data:h}=g(te({artistId:t})),{data:p}=g(ae({artistId:t})),b=(U=n==null?void 0:n.paymentToUserId)!=null?U:n==null?void 0:n.userId,{data:x}=g(ne(b)),d=x==null?void 0:x.stripeAccountId,[f,A]=r.useState(""),[q,Q]=r.useState(""),[E,V]=r.useState(null),[M,m]=r.useState(null),[T,I]=r.useState(null),[v,L]=r.useState(!1),[S,j]=r.useState(null),[Z,R]=r.useState(!1),J=r.useCallback(async e=>{if(d){for(let a=0;a<40;a++){const{result:l}=await $.get("purchase/".concat(e,"?stripeAccountId=").concat(d));if(m("Reader status: ".concat(l.status)),l.status==="succeeded"||l.status==="canceled"){j(null);return}await pe(1500)}m("Timed out waiting for the reader to complete. You can still cancel the payment.")}},[d]),Y=async()=>{if(!(!S||!d)){R(!0);try{const e=new URLSearchParams({stripeAccountId:d});f.trim()&&e.set("readerId",f.trim());const{result:a}=await $.delete("purchase/".concat(S,"?").concat(e));m("Payment ".concat(a.status,".")),j(null)}catch(e){m("Error canceling: ".concat(e.message))}finally{R(!1)}}},N=async(e,a)=>{var l;V(a),m(null),I(null),j(null),L(!0);try{const u=await $.post("purchase",{artistId:t,readerId:f.trim()||void 0,email:q.trim()||void 0,items:[e]});if(u.clientSecret)I({clientSecret:u.clientSecret}),m("Complete the online payment below.");else if(u.redirectUrl)m("Free purchase complete → ".concat(u.redirectUrl));else if(u.paymentIntentId||u.setupIntentId){const w=(l=u.paymentIntentId)!=null?l:u.setupIntentId;j(w),m("Dispatched to reader (".concat(w,"). Polling…")),await J(w)}else m("Purchase initiated.")}catch(u){m("Error: ".concat(u.message))}finally{L(!1)}};if(!n)return null;const C="flex flex-col gap-2 mb-6",P="flex items-center justify-between gap-3 py-2 border-b border-gray-200";return s.jsxs(me,{children:[s.jsx("h2",{className:"text-xl font-bold mb-1",children:"Point of sale"}),s.jsxs("p",{className:"text-sm mb-4",children:["Charges a single item through ",s.jsx("code",{children:"POST /v1/purchase"}),". Pick a Stripe Terminal reader for in-person card-present payments; leave it unset to complete an online payment with the Payment Element."]}),s.jsxs("div",{className:"flex flex-col gap-2 mb-6 max-w-md",children:[s.jsx("label",{className:"text-sm font-bold",htmlFor:"pos-reader",children:"Card reader (optional)"}),((O=(F=p==null?void 0:p.results)==null?void 0:F.length)!=null?O:0)>0?s.jsxs(ie,{id:"pos-reader",name:"readerId",value:f,onChange:e=>A(e.target.value),children:[s.jsx("option",{value:"",children:"No reader — online payment"}),p==null?void 0:p.results.map(e=>{var a,l;return s.jsxs("option",{value:e.id,children:[(a=e.label)!=null?a:e.id," (",e.deviceType,","," ",(l=e.status)!=null?l:"unknown",")"]},e.id)})]}):s.jsx(H,{id:"pos-reader",name:"readerId",placeholder:"tmr_...",value:f,onChange:e=>A(e.target.value)}),s.jsx("label",{className:"text-sm font-bold",htmlFor:"pos-email",children:"Buyer email (optional)"}),s.jsx(H,{id:"pos-email",name:"email",placeholder:"[email protected]",value:q,onChange:e=>Q(e.target.value)}),!d&&s.jsx("p",{className:"text-sm text-red-600",children:"This artist has no connected Stripe account — charges will fail."})]}),M&&s.jsxs("div",{className:"mb-4 p-3 rounded bg-gray-100 text-sm",children:[E&&s.jsxs("strong",{children:[E,": "]}),M]}),S&&s.jsx("div",{className:"mb-4",children:s.jsx(y,{size:"compact",variant:"outlined",onClick:Y,isLoading:Z,children:"Cancel payment"})}),T&&d&&s.jsx("div",{className:"mb-6 p-3 rounded border border-gray-300 max-w-md",children:s.jsx(xe,{clientSecret:T.clientSecret,stripeAccountId:d,onDone:e=>{m("Online payment: ".concat(e)),e==="succeeded"&&I(null)}})}),s.jsxs("div",{className:C,children:[s.jsx("h3",{className:"text-lg font-bold",children:"Releases"}),((_=c==null?void 0:c.results)!=null?_:[]).map(e=>{var a;return s.jsxs("div",{className:P,children:[s.jsxs("span",{children:[(a=e.title)!=null?a:"Untitled"," — ",k(e.minPrice,e.currency)]}),s.jsx(y,{size:"compact",disabled:v,onClick:()=>{var l;return N({type:"trackGroup",id:e.id},(l=e.title)!=null?l:"Release")},children:"Charge"})]},e.id)}),((z=c==null?void 0:c.results)!=null?z:[]).length===0&&s.jsx("p",{className:"text-sm",children:"No releases."})]}),s.jsxs("div",{className:C,children:[s.jsx("h3",{className:"text-lg font-bold",children:"Merch"}),((W=o==null?void 0:o.results)!=null?W:[]).map(e=>s.jsxs("div",{className:P,children:[s.jsxs("span",{children:[e.title," — ",k(e.minPrice,e.currency)]}),s.jsx(y,{size:"compact",disabled:v,onClick:()=>N({type:"merch",id:e.id,quantity:1},e.title),children:"Charge"})]},e.id)),((K=o==null?void 0:o.results)!=null?K:[]).length===0&&s.jsx("p",{className:"text-sm",children:"No merch."})]}),s.jsxs("div",{className:C,children:[s.jsx("h3",{className:"text-lg font-bold",children:"Subscriptions"}),s.jsx("p",{className:"text-sm",children:"Subscriptions require a reader id (online subscriptions are not yet supported by this endpoint)."}),((B=h==null?void 0:h.results)!=null?B:[]).map(e=>{var a;return s.jsxs("div",{className:P,children:[s.jsxs("span",{children:[e.name," — ",k(e.minAmount,(a=n.user)==null?void 0:a.currency)," ","/ ",e.interval.toLowerCase()]}),s.jsx(y,{size:"compact",disabled:v||!f.trim(),onClick:()=>N({type:"subscription",tierId:e.id},e.name),children:"Charge"})]},e.id)}),((D=h==null?void 0:h.results)!=null?D:[]).length===0&&s.jsx("p",{className:"text-sm",children:"No subscription tiers."})]})]})};export{Ne as default};
2//# sourceMappingURL=Index-Bp8mlhB7.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.