PageSourceSearch

https://app.aerials.ai/assets/CreditPaymentModel-CHyKfaG7.js

js aerials.ai collected 2026-10-05 15:10:46 UTC 8,573 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./react-vendor-y8TRZUmV.js";import{D as F,a as L,c as D,b as E,d as I}from"./dialog-yHj7xY3E.js";import{B as b,e as B,u as q,q as R}from"./index-CgDRHOIg.js";import{B as V}from"./badge-DpgB5hr4.js";import{E as z,u as O,a as T,P as K}from"./stripe-vendor-B2vOZ1_S.js";import{g as H}from"./stripe-B-SzjQZp.js";import{d as Q}from"./stripeConfig-Cc_Tl3Cx.js";import{a as U}from"./query-vendor-tmEgabp3.js";import{_,a0 as Y,c as G,L as M,t as J}from"./icons-vendor-CzWA3d2T.js";import"./radix-vendor-BjUB_I5y.js";import"./vendor-DaHVGnsy.js";import"./redux-vendor-i9Ejmy6W.js";import"./analytics-vendor-BS-zJC2A.js";import"./forms-vendor-DpO7iBSn.js";import"./pixel-vendor-B98mbuQ5.js";const A=[{credits:1,nonMemberPrice:29,memberPrice:20},{credits:5,nonMemberPrice:125,memberPrice:89},{credits:10,nonMemberPrice:229,memberPrice:159,bestValue:!0}];function W({selectedPack:y,selectedPrice:S,onSuccess:x,onBack:C}){const r=O(),s=T(),[g,a]=i.useState(!1),[l,c]=i.useState(null),[o,p]=i.useState(!1),{addMediaCredits:d,refreshSubscription:j}=q(),n=U(),N=async P=>{if(P.preventDefault(),!r||!s)return;a(!0),c(null);const{error:h}=await s.submit();if(h){c(h.message||"Form validation failed. Please try again."),a(!1);return}const{error:w,paymentIntent:m}=await r.confirmPayment({elements:s,confirmParams:{return_url:`${window.location.origin}/dashboard/billing?status=pack_success&pack=${y}`},redirect:"if_required"});if(w)c(w.message||"Payment failed. Please try again."),a(!1);else if(m){d(y);try{await B.post("/billing/confirm-media-pack-payment",{paymentIntentId:m.id,packSize:y})}catch(v){console.warn("Failed to confirm credits with backend:",v)}try{await j()}catch{console.warn("Failed to refresh subscription after purchase")}n.invalidateQueries({queryKey:R.billing.creditSummary()}),x()}};return e.jsxs("form",{onSubmit:N,className:"space-y-4 pt-2",children:[e.jsx(K,{options:Q,onReady:()=>p(!0)}),l&&e.jsx("p",{className:"text-xs text-red-500 mt-2",children:l}),o&&e.jsx(b,{type:"submit",disabled:g||!r,className:"w-full h-12 bg-slate-800 hover:bg-slate-900 text-white font-semibold text-base rounded-lg",children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):`Pay $${S}`}),e.jsx("p",{className:"text-xs text-center text-slate-500",children:"🔒 Secure payment powered by Stripe"})]})}function xe({open:y,onOpenChange:S,isPro:x,onSuccess:C,initialPack:r}){const[s,g]=i.useState(r??null),[a,l]=i.useState(r?"payment":"select"),[c,o]=i.useState(null),[p,d]=i.useState(!1),[j,n]=i.useState(null),N=H(),P=A.find(t=>t.credits===s),h=P?x?P.memberPrice:P.nonMemberPrice:0;i.useEffect(()=>{a==="payment"&&s&&!c&&!p&&(async()=>{if(!N){n("Stripe is not configured. Please set VITE_STRIPE_PUBLISHABLE_KEY.");return}d(!0),n(null);try{const u=(await B.post("/billing/stripe/create-media-pack-intent",{packSize:s,isPro:x}))?.data,$=u?.data?.clientSecret||u?.data?.client_secret||u?.clientSecret||u?.client_secret;if(!$||u?.status==="error"){n("Unable to start payment – missing client secret."),d(!1);return}o($)}catch(f){console.error("Error creating media pack payment intent",f);const u=f&&typeof f=="object"&&"response"in f?f?.response?.data?.message:void 0;n(u||"Something went wrong. Please try again.")}finally{d(!1)}})()},[a,s,x,c,p]);const w=()=>{s&&l("payment")},m=t=>{t||(l(r?"payment":"select"),g(r??null),o(null),n(null),d(!1)),S(t)},v=()=>{l("success")},k=()=>{m(!1),C?C():window.location.href="/dashboard/billing?status=pack_success&pack="+s};return e.jsx(F,{open:y,onOpenChange:m,children:e.jsxs(L,{className:"sm:max-w-lg bg-card/95 backdrop-blur-glass border-border/40",children:[a==="select"&&e.jsxs(e.Fragment,{children:[e.jsxs(D,{children:[e.jsx(E,{className:"tracking-tight text-2xl font-bold",children:"Aerial Credit Packs"}),e.jsx(I,{className:"text-base text-muted-foreground font-light",children:"1 Credit = All Aerial videos for one Property Card (Includes boundary, POI, and neighborhood video tours)"})]}),e.jsxs("div",{className:"space-y-4 sm:py-4 pt-0 pb-3",children:[e.jsx("div",{className:"space-y-3",children:A.map(t=>e.jsxs("div",{className:`relative p-4 rounded-lg border cursor-pointer transition-all ${s===t.credits?"border-primary bg-primary/10":t.bestValue?"border-amber-400/50 bg-amber-400/5 hover:border-primary/50":"border-border/30 hover:border-primary/50"}`,onClick:()=>g(t.credits),children:[t.bestValue&&e.jsx(V,{className:"absolute -top-2 right-4 bg-amber-400 text-amber-950 text-[10px]",children:"Best Value"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-5 w-5 rounded-full border-2 flex items-center justify-center ${s===t.credits?"border-primary bg-primary":"border-muted-foreground
1/30"}`,children:s===t.credits&&e.jsx(_,{className:"h-3 w-3 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-foreground",children:[t.credits," ",t.credits===1?"Credit":"Credits"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["All Aerial videos for ",t.credits," ",t.credits===1?"property":"properties"]})]})]}),e.jsx("div",{className:"text-right",children:x?e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground line-through",children:["$",t.nonMemberPrice]}),e.jsxs("p",{className:"font-bold text-foreground",children:["$",t.memberPrice]})]}):e.jsxs("div",{children:[e.jsxs("p",{className:"font-bold text-foreground",children:["$",t.nonMemberPrice]}),e.jsxs("p",{className:"text-xs text-primary",children:["Pro: $",t.memberPrice]})]})})]})]},t.credits))}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(b,{variant:"outline",onClick:()=>m(!1),className:"flex-1",children:"Cancel"}),e.jsx(b,{onClick:w,className:"flex-1 shadow-glow hover:shadow-glow-lg",disabled:!s,children:s?`Purchase ${s} Credit${s>1?"s":""}`:"Select a pack"})]})]})]}),a==="payment"&&e.jsxs(e.Fragment,{children:[e.jsxs(D,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:"ghost",size:"icon",className:"h-8 w-8 -ml-2",onClick:()=>{r?m(!1):(l("select"),o(null),n(null))},children:e.jsx(Y,{className:"h-4 w-4"})}),e.jsx(G,{className:"h-5 w-5 text-slate-700"}),e.jsx(E,{className:"text-xl font-bold text-slate-900",children:"Payment Details"})]}),e.jsxs(I,{className:"text-sm text-slate-600 mt-1",children:[s," Credit",s&&s>1?"s":""," — $",h]})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(M,{className:"h-6 w-6 animate-spin text-slate-600"})}),j&&e.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx("p",{className:"text-sm text-red-600",children:j}),e.jsx(b,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{n(null),o(null),d(!1)},children:"Try Again"})]}),!p&&!j&&c&&N&&s&&e.jsx(z,{stripe:N,options:{clientSecret:c,appearance:{theme:"stripe"}},children:e.jsx(W,{selectedPack:s,selectedPrice:h,onSuccess:v,onBack:()=>{l("select"),o(null)}})})]}),a==="success"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-emerald-500/10 flex items-center justify-center mb-4",children:e.jsx(J,{className:"h-8 w-8 text-emerald-500"})}),e.jsx(E,{className:"text-2xl font-bold mb-2",children:"Purchase Complete!"}),e.jsx(I,{className:"text-base text-muted-foreground mb-6",children:"Your credits have been added to your account and are ready to use."}),e.jsxs("div",{className:"w-full space-y-3",children:[e.jsxs("div",{className:"rounded-lg border border-border/30 bg-muted/20 p-4 text-left",children:[e.jsx("p",{className:"text-sm font-medium text-foreground mb-2",children:"Order Summary:"}),e.jsxs("ul",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Credits purchased:"}),e.jsx("span",{className:"font-medium text-foreground",children:s})]}),e.jsxs("li",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Amount paid:"}),e.jsxs("span",{className:"font-medium text-foreground",children:["$",h]})]}),e.jsxs("li",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Credits never expire"}),e.jsx(_,{className:"h-4 w-4 text-emerald-500"})]})]})]}),e.jsx(b,{onClick:k,className:"w-full",children:"Done"})]})]})})]})})}export{xe as CreditPaymentModel};

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.