PageSourceSearch

https://aidealer360.com/assets/BillingSetup-DgfE7g91.js

js aidealer360.com collected 2026-09-24 12:37:18 UTC 4,656 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-vendor-B12AOeKi.js";import{r as a}from"./react-vendor-DZt7wVAJ.js";import{p as w,s as l,P as u,q as c,B as p}from"./index-CUOC2qQu.js";import{p as x,E as N,a as k,b as v,g as S}from"./react-stripe.esm-CboF_eR4.js";import{C as E}from"./circle-check-CwVqBPQR.js";import{C as F}from"./credit-card-Dc3oH2Cx.js";import"./charts-vendor-B6q1L48j.js";import"./supabase-vendor-dOy44Gxq.js";import"./animation-vendor-BAVy02gd.js";const B={weekly:"Weekly",monthly:"Monthly",annual:"Annual"};function $(){const{toast:h}=w(),[g,r]=a.useState(!0),[t,b]=a.useState(null),[o,_]=a.useState(null),[m,d]=a.useState(!1),[f,y]=a.useState(!1);a.useEffect(()=>{(async()=>{const{data:{user:i}}=await l.auth.getUser();if(!i){r(!1);return}const{data:n}=await l.from("registration_users").select("id, name").eq("auth_uid",i.id).maybeSingle();if(!n){r(!1);return}const{data:s}=await l.from("m360_user_settings").select("billing_cycle, billing_amount_cents, billing_mode, access_status, stripe_subscription_id").eq("user_id",n.id).maybeSingle();b({id:n.id,name:n.name,billing_cycle:(s==null?void 0:s.billing_cycle)??null,billing_amount_cents:(s==null?void 0:s.billing_amount_cents)??null,billing_mode:(s==null?void 0:s.billing_mode)??null,access_status:(s==null?void 0:s.access_status)??null,stripe_subscription_id:(s==null?void 0:s.stripe_subscription_id)??null}),r(!1)})()},[]);const j=async()=>{if(!(!(t!=null&&t.billing_cycle)||!t.billing_amount_cents)){d(!0);try{const{data:i,error:n}=await l.functions.invoke("m360-billing",{body:{action:"checkout",userId:t.id,billingMode:"user_paid",billingCycle:t.billing_cycle,billingAmountCents:t.billing_amount_cents,environment:S(),returnUrl:`${window.location.origin}/marketplace360/billing-setup?checkout=done`}});if(n||!(i!=null&&i.clientSecret))throw new Error((n==null?void 0:n.message)||"No client secret");_(i.clientSecret)}catch(i){h({title:"Could not start checkout",description:i.message,variant:"destructive"})}finally{d(!1)}}};if(g)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center text-[#9FB3C8]",children:[e.jsx(u,{className:"h-5 w-5 animate-spin mr-2"})," Loading…"]});if(!t)return e.jsx("div",{className:"min-h-screen flex items-center justify-center text-[#9FB3C8] text-sm",children:"Please sign in to set up your subscription."});const C=t.access_status==="active"||!!t.stripe_subscription_id;return e.jsx("div",{className:"min-h-screen p-6 flex items-start justify-center",children:e.jsxs("div",{className:"w-full max-w-2xl space-y-4 mt-12",children:[e.jsxs("header",{className:"text-center space-y-1",children:[e.jsx("h1",{className:"text-2xl font-semibold text-[#E6EDF3]",children:"Activate Marketplace360"}),e.jsxs("p",{className:"text-sm text-[#9FB3C8]",children:[t.name?`Welcome, ${t.name}.`:"Welcome."," Set up your subscription to unlock access."]})]}),C||f?e.jsxs(c,{className:"p-8 bg-white/[0.03] border-white/10 text-center space-y-3",children:[e.jsx(E,{className:"h-10 w-10 text-emerald-400 mx-auto"}),e.jsx("div",{className:"text-lg text-[#E6EDF3]",children:"You're all set"}),e.jsx("p",{className:"text-sm text-[#9FB3C8]",children:"Your Marketplace360 access is now active."}),e.jsx(p,{onClick:()=>{window.location.href="/marketplace360"},children:"Go to Marketplace360"})]}):t.billing_mode!=="user_paid"||!t.billing_cycle||!t.billing_amount_cents?e.jsx(c,{className:"p-6 bg-white/[0.03] border-white/10 text-center text-sm text-[#9FB3C8]",children:"No paid plan is configured for your account. Please contact your administrator."}):o?e.jsx(c,{className:"p-2 bg-white border-white/10 overflow-hidden",children:e.jsx(N,{stripe:k(),options:{fetchClientSecret:()=>Promise.resolve(o),onComplete:()=>y(!0)},children:e.jsx(v,{})})}):e.jsxs(c,{className:"p-6 bg-white/[0.03] border-white/10 space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[#9FB3C8]",children:"Your plan"}),e.jsxs("div",{className:"text-lg text-[#E6EDF3]",children:["Marketplace360 — ",B[t.billing_cycle]," · $",(t.billing_amount_cents/100).toFixed(2)]}),e.jsxs("p",{className:"text-xs text-[#9FB3C8]",children:["Billed ",t.billing_cycle,". Cancel anytime from your billing portal."]})]}),e.jsx(p,{onClick:j,disabled:m||!x(),className:"w-full",children:m?e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"h-4 w-4 mr-2 animate-spin"}),"Preparing checkout…"]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),"Continue to payment"]})}),!x()&&e.jsx("p",{className:"text-[11px] text-amber-300 text-center",children:"Payments are not configured for this build."})]})]})})}export{$ 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.