PageSourceSearch

https://feruza.ai/assets/Subscription-DOz5cpRw.js

js feruza.ai collected 2026-10-05 15:08:50 UTC 16,574 bytes, 1 lines download raw bytes

1import{r as t,j as e}from"./ui-bShnqivU.js";import{g as xe,ak as he,i as pe,s as k,L as j,B as l,a0 as ge,r as m,w as u,S as T,t as y,a1 as N,C as U,v as je,be as fe,ao as be,b as M,ah as R,ai as $,a7 as v,a4 as ye,af as Ne,ag as ve,A as q,k as O,l as H,m as G,n as K,o as V,p as W,q as X}from"./index-DC90iBAH.js";import{S as w}from"./separator-4i_tOti6.js";import{u as we}from"./useDocumentMeta-Dl_k8qXo.js";import{u as Ce,d as _e,L as J}from"./vendor-DFFZ_pB-.js";import{C as A}from"./calendar-u_5s5WDQ.js";import{C as Se,a as ke}from"./circle-arrow-up-BWCT-pnp.js";import{C as Ae}from"./circle-x-rG4UkLV8.js";import{D as De}from"./download-Dx1LceoU.js";import"./supabase-BJyh81Im.js";import"./motion-DXxyDEr_.js";import"./markdown-CP1Sy82H.js";const i=a=>new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric"}).format(new Date(a)),Q=(a,P)=>new Intl.NumberFormat("en-EU",{style:"currency",currency:P.toUpperCase()}).format(a/100),D=a=>a.charAt(0).toUpperCase()+a.slice(1);function Oe(){we({title:"Subscription plans — Feruza AI",description:"Choose your Feruza AI subscription plan, top up credits, and manage upgrades, downgrades, and renewals for AI tax advisory.",canonicalPath:"/subscription"});const{session:a,user:P}=xe(),{subscribed:Pe,overridden:F,overrideReason:Z}=he(),x=Ce(),{toast:c}=pe(),[ee,Y]=t.useState(!0),[d,I]=t.useState(!1),[h,z]=t.useState(!1),[r,se]=t.useState(null),[p,re]=t.useState(null),[L,ae]=t.useState([]),[g,te]=t.useState(null),[ie,C]=t.useState(!1),[o,f]=t.useState(null),[B,Fe]=t.useState(null);_e();const ne=fe,le=be,ce=async s=>{x(`/checkout/pay?creditPack=${encodeURIComponent(s)}`)},b=t.useCallback(async()=>{if(a){Y(!0);try{const{data:s,error:n}=await k.functions.invoke("get-subscription-details",{headers:{Authorization:`Bearer ${a.access_token}`}});if(n)throw n;se(s?.subscription??null),re(s?.payment_method??null),ae(s?.invoices??[]),te(s?.scheduled_change??null)}catch{c({title:"Error",description:"Failed to load subscription details",variant:"destructive"})}finally{Y(!1)}}},[a?.access_token]);t.useEffect(()=>{b()},[b]);const E=async s=>{I(!0);try{const{data:n,error:S}=await k.functions.invoke("cancel-subscription",{headers:{Authorization:`Bearer ${a.access_token}`},body:{action:s}});if(S||!n?.success)throw new Error;c({title:s==="cancel"?"Subscription cancelled":"Subscription resumed",description:s==="cancel"?"Your subscription will end at the current billing period.":"Your subscription has been renewed."}),await b()}catch{c({title:"Error",description:"Action failed. Please try again.",variant:"destructive"})}finally{I(!1),C(!1)}},de=async s=>{z(!0);try{const{data:n,error:S}=await k.functions.invoke("switch-plan",{headers:{Authorization:`Bearer ${a.access_token}`},body:{target_plan:s}});if(S||!n?.success){c({title:"Error",description:n?.error||"Failed to switch plan",variant:"destructive"});return}c({title:"Plan Change Scheduled",description:n.message}),await b()}catch{c({title:"Error",description:"Something went wrong",variant:"destructive"})}finally{z(!1),f(null)}},oe=r?.interval==="year"?"Yearly":"Monthly",_=r?.trial_end&&new Date(r.trial_end)>new Date,me=r&&r.interval==="month"&&!r.cancel_at_period_end&&!g,ue=r&&r.interval==="year"&&!r.cancel_at_period_end&&!g;return ee?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(j,{className:"h-6 w-6 animate-spin text-primary"})}):e.jsxs("div",{className:"min-h-screen pt-nav px-4 sm:px-6 pb-12 bg-background mt-4",children:[e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(l,{variant:"ghost",size:"icon",onClick:()=>x("/dashboard"),children:e.jsx(ge,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage your Feruza AI plan"})]})]}),F&&e.jsx(m,{className:"border-primary/30 bg-primary/5",children:e.jsxs(u,{className:"p-5 flex items-start gap-3",children:[e.jsx(T,{className:"h-5 w-5 text-primary shrink-0 mt-0.5"}),e.jsx("div",{className:"text-sm space-y-1",children:(()=>{const s=(Z||"").toLowerCase();return s==="corporate"||s==="business"?e.jsx("p",{children:"Subscription managed by your organization. Please contact your respective administrator for any changes or enquiries."}):s==="admin"?e.jsx("p",{children:"Your subscription is granted as part of your administrator privileges. This access is managed internally."}):s==="partner"?e.jsx("p",{children:"Your subscription is provided through a partner agreement. For any changes, please contact your partner representative."}):s==="free"?e.jsx("p",{children:"You have been granted complimentary access. No billing actions are required."}):s==="promo"?e.jsx("p",{children:"Your subscription is active through a promotional offer. No billing actions are required."}):e.jsx("p",{children:"Your subscription is managed externally. Contact your administrator or support for changes."})})()})]})}),!r&&!F&&e.jsxs(e.Fragment,{children:[e.jsxs(m,{className:"border-primary/20",children:[e.jsxs(y,{className:"pb-3",children:[e.jsxs(N,{className:"text-lg flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5 text-primary"}),"Buy Credits"]}),e.jsx(je,{children:"No commitment needed. Purchase credits for individual AI consultations — credits never expire."})]}),e.jsxs(u,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:ne.map(s=>e.jsxs("button",{onClick:()=>ce(s.id),disabled:!!B,className:"rounded-lg border border-border/60 bg-muted/30 p-4 text-center hover:border-primary/40 hover:bg-muted/50 transition-all disabled:opacity-50",children:[B===s.id?e.jsx(j,{className:"h-5 w-5 animate-spin mx-auto mb-2"}):e.jsx(U,{className:"h-5 w-5 text-primary mx-auto mb-2"}),e.jsx("p",{className:"font-semibold text-lg",children:s.credits}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"credits"}
1),e.jsx("p",{className:"text-sm font-medium mt-1 text-primary",children:s.priceLabel}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:["€",(s.priceCents/s.credits/100).toFixed(2),"/credit"]})]},s.id))}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 text-xs",children:Object.entries(le).map(([s,n])=>e.jsxs("div",{className:"flex items-center justify-between gap-1 px-2 py-1.5 rounded-md bg-muted/30",children:[e.jsx("span",{className:"text-muted-foreground truncate",children:n.label}),e.jsxs("span",{className:"font-medium shrink-0",children:[n.cost," cr"]})]},s))})]})]}),e.jsx(m,{className:"border-border/50 bg-gradient-to-br from-primary/5 to-transparent",children:e.jsxs(u,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl gradient-teal flex items-center justify-center shrink-0",children:e.jsx(M,{className:"h-5 w-5 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Want unlimited access? Upgrade to a subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Get more value with a subscription — starting at just €39.99/month with up to 120 consultations included."})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs text-muted-foreground",children:["All AI modules included","Up to 2000 consultations/mo","Document analysis & review","Priority model access","Multi-user team support","7-day free trial available"].map(s=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(R,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{children:s})]},s))}),e.jsxs(l,{className:"gradient-teal text-primary-foreground",onClick:()=>x("/checkout"),children:[e.jsx($,{className:"h-4 w-4 mr-2"}),"View Subscription Plans"]})]})})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(m,{children:[e.jsx(y,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(N,{className:"text-lg",children:"Current Plan"}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.cancel_at_period_end&&e.jsxs(v,{variant:"outline",className:"text-amber-500 border-amber-500/30 bg-amber-500/10",children:[e.jsx(ye,{className:"h-3 w-3 mr-1"}),"Cancelling"]}),_&&e.jsx(v,{variant:"outline",className:"text-blue-500 border-blue-500/30 bg-blue-500/10",children:"Free Trial"}),e.jsx(v,{className:["active","trialing"].includes(r.status)?"bg-emerald-500/15 text-emerald-500 border-emerald-500/30":"bg-muted text-muted-foreground",children:r.cancel_at_period_end?"Active until end of period":D(r.status)})]})]})}),e.jsxs(u,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:Q(r.amount,r.currency)}),e.jsxs("span",{className:"text-muted-foreground",children:["/",r.interval]})]}),e.jsxs("p",{className:"text-sm font-medium",children:["Feruza AI Pro — ",oe]}),e.jsx(w,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{children:["Current period: ",i(r.current_period_start)," — ",i(r.current_period_end)]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:r.cancel_at_period_end?`Ends ${i(r.current_period_end)}`:`Renews ${i(r.current_period_end)}`})]}),_&&r.trial_end&&e.jsxs("div",{className:"flex items-center gap-2 text-blue-500",children:[e.jsx(M,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{children:["Trial ends ",i(r.trial_end)]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{children:["Subscribed since ",i(r.created)]})]})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx(w,{}),e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[e.jsx(Ne,{className:"h-5 w-5 text-blue-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm space-y-1",children:[e.jsx("p",{className:"font-medium text-blue-600 dar
1k:text-blue-400",children:"Plan Change Scheduled"}),e.jsxs("p",{className:"text-muted-foreground",children:["Your plan will switch to ",g.target_interval==="year"?"Yearly":"Monthly"," on ",i(g.effective_date),"."]})]})]})]}),e.jsx(w,{}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:["AI-powered tax assistance","Unlimited conversations","Document analysis & support","Secure & encrypted data","IFRS & Accounting module","Banking & Compliance module"].map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-primary shrink-0"}),s]},s))}),e.jsx(w,{}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.cancel_at_period_end?e.jsxs(l,{onClick:()=>E("resume"),disabled:d,className:"gradient-teal text-primary-foreground",children:[d?e.jsx(j,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ve,{className:"h-4 w-4 mr-2"}),"Resume Subscription"]}):e.jsxs(e.Fragment,{children:[me&&e.jsxs(l,{variant:"outline",onClick:()=>f("upgrade"),disabled:h,className:"text-primary border-primary/30 hover:bg-primary/10",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Upgrade to Yearly"]}),ue&&e.jsxs(l,{variant:"outline",onClick:()=>f("downgrade"),disabled:h,className:"text-muted-foreground border-border hover:bg-muted/50",children:[e.jsx(ke,{className:"h-4 w-4 mr-2"}),"Switch to Monthly"]}),e.jsxs(l,{variant:"outline",onClick:()=>C(!0),disabled:d,className:"text-destructive border-destructive/30 hover:bg-destructive/10",children:[e.jsx(Ae,{className:"h-4 w-4 mr-2"}),"Cancel Subscription"]})]})})]})]}),e.jsxs(m,{children:[e.jsx(y,{className:"pb-3",children:e.jsx(N,{className:"text-lg",children:"Payment Method"})}),e.jsx(u,{children:p?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-10 w-14 rounded-md border bg-card flex items-center justify-center",children:e.jsx($,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[D(p.brand)," •••• ",p.last4]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Expires ",String(p.exp_month).padStart(2,"0"),"/",p.exp_year]})]})]}),e.jsx(l,{variant:"outline",size:"sm",onClick:()=>x("/update-payment"),children:"Update"})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No payment method on file"}),e.jsx(l,{variant:"outline",size:"sm",onClick:()=>x("/update-payment"),children:"Add Card"})]})})]}),L.length>0&&e.jsxs(m,{children:[e.jsx(y,{className:"pb-3",children:e.jsx(N,{className:"text-lg",children:"Billing History"})}),e.jsx(u,{className:"p-0",children:e.jsx("div",{className:"divide-y divide-border",children:L.map(s=>e.jsxs("div",{className:"flex items-center justify-between px-6 py-3",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:s.number||"Invoice"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i(s.created)})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(v,{variant:"outline",className:s.status==="paid"?"text-emerald-500 border-emerald-500/30":"",children:s.status==="paid"?"Paid":D(s.status||"unknown")}),e.jsx("span",{className:"text-sm font-medium min-w-[70px] text-right",children:Q(s.amount_paid,s.currency)}),s.invoice_pdf&&e.jsx(l,{variant:"ghost",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:s.invoice_pdf,target:"_blank",rel:"noopener noreferrer",children:e.jsx(De,{className:"h-4 w-4"})})})]})]},s.id))})})]})]}),e.jsxs("div",{className:"text-center text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{className:"flex items-center justify-center gap-1",children:[e.jsx(T,{className:"h-3 w-3"}),"Payments securely processed by Stripe"]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(J,{to:"/refund-policy",className:"text-primary hover:underline",children:"Refund Policy"}),e.jsx("span",{children:"•"}),e.jsx(J,{to:"/terms",className:"text-primary hover:underline",children:"Terms of Service"})]})]})]}),e.jsx(q,{open:ie,onOpenChange:C,children:e.jsxs(O,{children:[e.jsxs(H,{
1children:[e.jsx(G,{children:"Cancel Subscription?"}),e.jsx(K,{children:_?e.jsxs(e.Fragment,{children:["You are currently on a free trial. If you cancel now, your trial will end immediately and no charges will apply. Your subscription will remain active until ",r?i(r.trial_end||r.current_period_end):"","."]}):e.jsxs(e.Fragment,{children:["Your subscription will remain active until the end of your current billing period (",r?i(r.current_period_end):"","). After that, you'll lose access to Feruza AI Pro features. You can resume anytime before the period ends."]})})]}),e.jsxs(V,{children:[e.jsx(W,{disabled:d,children:"Keep Subscription"}),e.jsxs(X,{onClick:()=>E("cancel"),disabled:d,className:"bg-destructive text-destructive-foreground",children:[d&&e.jsx(j,{className:"h-4 w-4 animate-spin mr-2"}),"Cancel Subscription"]})]})]})}),e.jsx(q,{open:!!o,onOpenChange:s=>!s&&f(null),children:e.jsxs(O,{children:[e.jsxs(H,{children:[e.jsx(G,{children:o==="upgrade"?"Upgrade to Yearly Plan?":"Switch to Monthly Plan?"}),e.jsx(K,{children:o==="upgrade"?e.jsxs(e.Fragment,{children:["Your plan will switch to Yearly (€917/year) at the end of your current monthly billing period (",r?i(r.current_period_end):"","). You'll save ~15% compared to the monthly plan. No free trial is included for upgrades."]}):e.jsxs(e.Fragment,{children:["Your plan will switch to Monthly (€89.99/month) at the end of your current yearly billing period (",r?i(r.current_period_end):"","). You'll be charged the monthly rate going forward."]})})]}),e.jsxs(V,{children:[e.jsx(W,{disabled:h,children:"Cancel"}),e.jsxs(X,{onClick:()=>de(o==="upgrade"?"yearly":"monthly"),disabled:h,className:o==="upgrade"?"gradient-teal text-primary-foreground":"",children:[h&&e.jsx(j,{className:"h-4 w-4 animate-spin mr-2"}),o==="upgrade"?"Upgrade to Yearly":"Switch to Monthly"]})]})]})})]})}export{Oe 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.