PageSourceSearch

https://turnkeyhome.ai/assets/PropertyBilling-Cr-AnnCg.js

js turnkeyhome.ai collected 2026-10-05 15:55:59 UTC 12,330 bytes, 1 lines download raw bytes

1import{q as se,b as ae,I as re,J as te,u as ie,r as h,ak as P,H as f,G as ne,K as n,j as e,x as c,bD as ce,W as le,C as l,s as m,t as u,O as de,l as d,w as j,T as oe,b0 as F,b1 as _,Z as me,cb as ue,ch as N,a8 as T,cc as xe,bC as he,v as je,p as ge,cu as pe,U as fe,bF as Ne}from"./index-DD-ZZ9ri.js";import{A as ye}from"./AdminQuickAccess-BdtOF328.js";import"./chart-column-B07bi-wz.js";import"./activity-DShDB3AB.js";import"./bot-BxnelbMm.js";function _e(){const $=se(),[y]=ae(),{currentProperty:t,loading:B}=re(),{subscription:a,plans:M,creditPacks:R,loading:Y,trialDaysRemaining:D,isTrialExpired:z,getTeamLimits:O,refetchSubscription:S}=te(),{user:x}=ie(),[k,A]=h.useState(null),[g,U]=h.useState(null),Q=P(f.stripe.createCheckoutSession),H=P(f.stripe.purchaseCredits),W=P(f.stripe.createPortalSession),v=ne(f.properties.getTeamCounts),[p,q]=h.useState({admins:0,managers:0});if(h.useEffect(()=>{v&&q(v)},[v]),h.useEffect(()=>{y.get("success")==="true"?(n.success("Payment successful! Your credits have been added."),S()):y.get("canceled")==="true"&&n.info("Payment was canceled.")},[y,S]),B||Y)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})});if(!t)return null;const Z=D(),E=z(),I=(a==null?void 0:a.credits_remaining)||0,b=(a==null?void 0:a.credits_monthly)||30,G=b>0?Math.min(I/b*100,100):0,i=O(),J=async s=>{if(!x){n.error("Please sign in to upgrade");return}A(s);try{const r=await Q({planName:s,successUrl:`${window.location.origin}/property/${t.slug}/billing?success=true`,cancelUrl:`${window.location.origin}/property/${t.slug}/billing?canceled=true`,userId:x._id});if(r.url)window.location.href=r.url;else throw new Error("No checkout URL returned")}catch(r){console.error("Error creating checkout session:",r),n.error("Failed to start checkout. Please try again.")}finally{A(null)}},L=async(s,r)=>{if(!x){n.error("Please sign in to purchase credits");return}U(`${s}-${r?"recurring":"onetime"}`);try{const o=await H({packId:s,recurring:r,successUrl:`${window.location.origin}/property/${t.slug}/billing?success=true&type=credits`,cancelUrl:`${window.location.origin}/property/${t.slug}/billing?canceled=true`,userId:x._id});if(o.url)window.location.href=o.url;else throw new Error("No checkout URL returned")}catch(o){console.error("Error purchasing credits:",o),n.error("Failed to start checkout. Please try again.")}finally{U(null)}},K=async()=>{if(!x){n.error("Please sign in");return}try{const s=await W({returnUrl:`${window.location.origin}/property/${t.slug}/billing`,userId:x._id});s.url&&(window.location.href=s.url)}catch(s){console.error("Error creating portal session:",s),n.error("Failed to open billing portal. Please try again.")}},V=s=>{switch(s){case"starter":return Ne;case"pro":return fe;case"business":return pe;default:return F}},w=s=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(s/100);return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(c,{variant:"ghost",size:"sm",onClick:()=>$(`/property/${t.slug}`),children:[e.jsx(ce,{className:"h-4 w-4 mr-2"}),"Back to Property"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>$("/dashboard"),children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),"Dashboard"]}),e.jsx(ye,{})]})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:t.name}),e.jsx("p",{className:"text-muted-foreground",children:"Billing & Credits"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs(l,{children:[e.jsx(m,{className:"pb-2",children:e.jsxs(u,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),"Current Plan"]})}),e.jsxs(d,{children:[e.jsx("p",{className:"text-2xl font-bold capitalize",children:(a==null?void 0:a.plan_name)||"Free"}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:(a==null?void 0:a.status)==="trialing"&&!E?e.jsxs(j,{variant:"secondary",className:"text-xs",children:[e.jsx(oe,{className:"h-3 w-3 mr-1"}),"Trial: ",Z," days left"]}):(a==null?void 0:a.status)==="active"?e.jsx(j,{variant:"default",className:"text-xs",children:"Active"}):e.jsx(j,{variant:"destructive",className:"text-xs",children:E?"Trial Expired":"Inactive"})})]})]}),e.jsxs(l,{children:[e.jsx(m,{className:"pb-2",children:e.jsxs(u,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(F,{className:"h-4 w-4"}),"Credits Available"]})}),e.jsxs(d,{children:[e.jsx("p",{className:"text-2xl font-bold",children:I}),e.jsx(_,{value:G,className:"mt-2 h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[b,"/mo • Resets monthly"]})]})]}),e.jsxs(l,{children:[e.jsx(m,{className:"pb-2",children:e.jsxs(u,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"Team Capacity"]})}),e.jsxs(d,{className:"text-xs space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{children:"Admins"}),e.jsxs("span",{className:"font-medium",children:[p.admins," / ",i.maxAdmins]})]}),e.jsx(_,{value:p.admins/i.maxAdmins*100,className:"h-1.5"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{children:"Managers"}),e.jsxs("span",{className:"font-medium",children:[p.managers," / ",i.maxManagers===0?"0":i.maxManagers]})]}),e.jsx(_,{value:i.maxManagers>0?p.managers/i.maxManagers*100:0,className:"h-1.5"}),i.overagePrice&&e.jsxs("p",{className:"text-muted-foreground pt-1",children:["+",w(i.overagePrice),"/seat over limit"]})]})]}),e.jsxs(l,{children:[e.jsx(m,{className:"pb-2",children:e.jsxs(u,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Credit Costs"]})}),e.jsxs(d,{className:"text-xs space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"AI Analysis"}),e.jsxs("span",{className:"font-medium",children:[N["ai-analyze"]," credits"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"AI Estimates"}),e.jsxs("span",{className:"font-medium",children:[N["ai-estimate"]," credits"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"AI Visualization"}),e.jsxs("span",{className:"font-medium",children:[N["ai-visualize"]," credits"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Image Editing"}),e.jsxs("span",{className:"font-medium",children:[N["ai-edit-image"]," credits"]})]})]})]})]}),(a==null?void 0:a.stripe_subscription_id)&&e.jsx(l,{children:e.jsx(d,{className:"py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Manage Your Subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Update payment method, view invoices, or cancel"})]}),e.jsx(c,{variant:"outline",onClick:K,children:"Open Billing Portal"})]})})}),e.jsx(T,{}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Buy More Credits"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"One-time purchase or set up monthly auto-buy. Purchased packs never expire!"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:R.map(s=>e.jsxs(l,{className:"relative",children:[s.discount_percent>0&&e.jsx("div",{className:"absolute -top-2 -right-2",children:e.jsx(j,{className:"bg-green-500 text-white text-xs",children:s.discount_percent===15?"15% Bonus":s.discount_percent===30?"30% Bonus":s.discount_percent>=40?"Super Saver":`${s.discount_percent}% OFF`})}),e.jsx(m,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-5 w-5 text-primary"}),e.jsx(u,{className:"text-lg",children:s.name})]})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-3xl font-bold",children:w(s.price_cents)}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(s.price_cents/s.credits).toFixed(1),"¢ per credit"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"w-full",onClick:()=>L(s.id,!1),disabled:g===`${s.id}-onetime`,children:g===`${s.id}
1-onetime`?"Loading...":"Buy Once"}),e.jsxs(c,{variant:"outline",className:"w-full",onClick:()=>L(s.id,!0),disabled:g===`${s.id}-recurring`,children:[e.jsx(he,{className:"h-3 w-3 mr-2"}),g===`${s.id}-recurring`?"Loading...":"Monthly"]})]})]})]},s.id))})]}),e.jsx(T,{}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Choose Your Plan"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Upgrade to get more monthly AI credits and unlock team features"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:M.map(s=>{const r=V(s.name),o=(a==null?void 0:a.plan_name)===s.name,C=s.name==="pro";return e.jsxs(l,{className:`relative ${C?"border-primary shadow-lg":""} ${o?"bg-primary/5":""}`,children:[C&&e.jsx("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2",children:e.jsx(j,{className:"bg-primary text-primary-foreground",children:"Most Popular"})}),e.jsx(m,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg flex items-center justify-center ${s.name==="free"?"bg-muted":s.name==="starter"?"bg-blue-500/10":s.name==="pro"?"bg-primary/10":"bg-premium/10"}`,children:e.jsx(r,{className:`h-5 w-5 ${s.name==="free"?"text-muted-foreground":s.name==="starter"?"text-blue-500":s.name==="pro"?"text-primary":"text-premium"}`})}),e.jsxs("div",{children:[e.jsx(u,{className:"text-lg",children:s.display_name}),e.jsxs(je,{children:[s.credits_monthly," credits/mo"]})]})]})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-3xl font-bold",children:s.price_cents===0?"Free":w(s.price_cents)}),s.price_cents>0&&e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2 text-sm",children:s.features.map((X,ee)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"}),e.jsx("span",{children:X})]},ee))}),o?e.jsx(c,{variant:"outline",className:"w-full",disabled:!0,children:"Current Plan"}):s.price_cents===0?e.jsx(c,{variant:"outline",className:"w-full",disabled:!0,children:"Free Forever"}):e.jsx(c,{className:"w-full",variant:C?"default":"outline",onClick:()=>J(s.name),disabled:k===s.name,children:k===s.name?"Loading...":"Upgrade"})]})]},s.id)})})]}),e.jsxs(l,{className:"bg-muted/30",children:[e.jsx(m,{children:e.jsx(u,{children:"Frequently Asked Questions"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Do unused credits roll over?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Yes! Unused credits roll over month to month and never expire. Plus, you can buy additional credit packs anytime."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"What happens when I run out of credits?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You can purchase additional credit packs at any time, or set up a monthly auto-buy to ensure you never run out."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Can I cancel anytime?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Yes! You can cancel your subscription at any time. You'll keep any remaining credits and continue to have access until they're used."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"What are the team member limits?"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Each plan includes a set number of admin and manager seats. The Business plan allows additional seats at $8/month each beyond the included 20 managers."})]})]})]})]})})})}export{_e 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.