PageSourceSearch

https://the-gazel.lovable.app/assets/Products-Crn-r-Ab.js

js the-gazel.lovable.app collected 2026-10-03 03:50:12 UTC 16,285 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-BcZpBtGC.js";import{r as d}from"./vendor-CbTYwD9p.js";import{u as O,d as R,b as I,E as z,y as B,C as U,e as G,g as V,h as W,a as q,P as ee,a9 as se,B as N,s as te,l as H,O as T,ay as re,U as ae,az as ie,F as ne,$ as ce,o as oe,ax as le,aA as de,a0 as ue,S as me,aa as pe,aB as xe,aC as he,aD as M,J as k,f as ge,K as P,M as A,a1 as be,R as fe}from"./index-D4z10nuM.js";import{u as je,a as K,L as J}from"./router-C21RS5Se.js";import{S as Ne}from"./switch-DoKIjmrj.js";import{C as ve}from"./chart-no-axes-gantt-DgXaQ5Kx.js";import{W as ye}from"./workflow-BLQAs09L.js";import{R as we}from"./repeat-6WWf74Qp.js";import{G as Se}from"./gem-Ky2B3fRN.js";function Ce(){const l=je(),{user:n}=O();d.useEffect(()=>{l.pathname&&o({event_type:"page_view",page_path:l.pathname})},[l.pathname]);const o=d.useCallback(async t=>{try{console.log("Analytics event:",{...t,user_id:(n==null?void 0:n.id)||"anonymous",timestamp:new Date().toISOString()})}catch(u){console.error("Error tracking analytics event:",u)}},[n]),p=d.useCallback((t,u)=>{o({event_type:"feature_use",feature_name:t,metadata:u})},[o]),v=d.useCallback((t,u,i)=>{o({event_type:{view:"subscription_view",start:"subscription_start",complete:"subscription_complete"}[t],subscription_plan:u,metadata:i})},[o]),x=d.useCallback((t,u)=>{o({event_type:"error",error_message:t,metadata:u})},[o]);return{trackEvent:o,trackFeatureUse:p,trackSubscriptionFlow:v,trackError:x}}const ke=()=>{const[l,n]=d.useState([]),[o,p]=d.useState(!0),[v,x]=d.useState(null),[t,u]=d.useState("monthly"),{toast:i}=R(),{user:f}
1=O(),{trackSubscriptionFlow:h,trackError:g}=Ce(),{status:m,isLoading:r,refetchStatus:b,isSubscribed:E,isTrialActive:_,canSubscribe:y,subscribe:F}=I();K();const D=(s,c)=>{const a=s.toLowerCase();return a.includes("basic")||c===0?["Basic expense tracking","Tax deduction identification","Standard reports"]:a.includes("starter")?["Bank account connection","Monthly reports","Email support"]:a.includes("professional")||a.includes("premium")?["AI-powered suggestions","Receipt scanning","Advanced analytics"]:["Tax strategy planning","Priority support","Custom reports"]},$=(s,c)=>{const a=s.toLowerCase();return a.includes("basic")||c===0?"basic":a.includes("starter")?"starter":a.includes("professional")||a.includes("premium")?"premium":"enterprise"};d.useEffect(()=>{(async()=>{try{const{data:c,error:a}=await te.from("products").select("*").eq("active",!0);if(a)throw a;n(c||[]),h("view",void 0,{product_count:(c==null?void 0:c.length)||0})}catch(c){console.error("Error fetching products:",c),g("Products fetch failed",{source:"PaymentProducts"}),i({title:"Error",description:"Could not load products. Please try again.",variant:"destructive"})}finally{p(!1)}})()},[i,h,g]),d.useEffect(()=>{f&&b()},[f,b]);const Y=async s=>{console.log("Subscribe button clicked for product:",s.name);const c=$(s.name,s.price);if(c==="basic"||s.price===0){i({title:"Free Trial Available",description:"Start your 14-day free trial to access all features.",variant:"default"});return}if(c==="enterprise"){i({title:"Coming Soon",description:"Enterprise features are coming soon. Please contact support for more information.",variant:"default"});return}if(!f){i({title:"Authentication Required",description:"Please log in to subscribe to a plan.",variant:"destructive"});return}if(!y(s.id)){i({title:"Subscription Error",description:"You already have an active subscription.",variant:"destructive"});return}
1x(s.id);try{console.log("Starting subscription process for product:",s.id),h("start",s.name,{price:s.price,currency:s.currency});const a=await F(s.id,t==="annual"?"year":"month");if(console.log("Subscription response:",a),a!=null&&a.url)console.log("Redirecting to Stripe checkout:",a.url),window.open(a.url,"_blank"),i({title:"Subscription Initiated",description:"Redirecting to secure payment...",variant:"default"}),setTimeout(()=>{b()},3e3);else throw new Error("No checkout URL received from Stripe")}catch(a){console.error("Error creating subscription:",a),g("Subscription creation failed",{product_id:s.id,product_name:s.name,error_message:a instanceof Error?a.message:"Unknown error"}),i({title:"Subscription Failed",description:a instanceof Error?a.message:"Could not process subscription.",variant:"destructive"})}finally{x(null)}},w=t==="annual",Z=s=>{if(s===0)return{main:"Free Trial",sub:null};const c=s/100;if(w){const a=c*10;return{main:`$${a.toFixed(2)}/year`,sub:`~$${(a/12).toFixed(2)}/mo`,crossed:`$${(c*12).toFixed(2)}`}}return{main:`$${c.toFixed(2)}/month`,sub:null}};return o||r?e.jsx("div",{className:"flex justify-center items-center p-8",children:e.jsx(z,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8 space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsx(B,{htmlFor:"billing-toggle",className:`text-sm font-medium ${w?"text-muted-foreground":"text-foreground"}`,children:"Monthly"}),e.jsx(Ne,{id:"billing-toggle",checked:w,onCheckedChange:s=>u(s?"annual":"monthly")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{htmlFor:"billing-toggle",className:`text-sm font-medium ${w?"text-foreground":"text-muted-foreground"}`,children:"Annual"}),w&&e.jsx("span",{className:"bg-green-100 text-green-700 text-xs font-semibold px-2 py-0.5 rounded-full",children:"Save 17%"})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:l.map(s=>{const c=$(s.name,s.price),a=D(s.name,s.price),S=E&&(m==null?void 0:m.plan)&&s.name.toLowerCase().includes(m.plan.toLowerCase()),L=c==="basic"||s.price===0,C=c==="premium",Q=!y(s.id)&&!L||S;return e.jsxs(U,{className:`relative flex flex-col ${C?"border-primary shadow-lg":"border-border"} ${S?"border-green-500":""} transition-all duration-200 hover:shadow-md`,children:[C&&e.jsx("div",{className:"absolute -top-3 left-1/2 transform -translate-x-1/2",children:e.jsx("div",{className:"bg-primary text-primary-foreground px-4 py-1 rounded-full text-sm font-medium",children:"Most Popular"})}),e.jsxs(G,{className:"text-center pb-2",children:[e.jsx(V,{className:"text-xl font-semibold",children:s.name}),e.jsx("div",{className:"mt-4",children:(()=>{const j=Z(s.price);return e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-bold text-foreground",children:j.main}),j.sub&&e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground",children:[j.sub,j.crossed&&e.jsx("span",{className:"ml-2 line-through text-muted-foreground/50",children:j.crossed})]})]})})()}),e.jsx(W,{className:"mt-2 text-sm",children:s.description})]}),e.jsx(q,{className:"flex-grow px-6",children:e.jsx("ul",{className:"space-y-3",children:a.map((j,X)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(ee,{className:"h-4 w-4 text-green-500 mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-foreground",children:j})]},X))})}),e.jsx(se,{className:"pt-6",children:e.jsx(N,{onClick:()=>Y(s),disabled:v===s.id||Q&&!L,className:`w-full ${C?"bg-primary hover:bg-primary/90":""}`,variant:S?"outline":C?"default":"outline",size:"lg",children:v===s.id?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):S?"Current Plan":L?"Start Free Trial":y(s.id)?"Get Started":"Already Subscribed"})})]},s.id)})})]})},Pe=[{id:"gazelfaith",name:"GazelFaith",description:"Complete non-profit & religious finance management",price:"$29.99",priceLabel:"/month per organization",trialDays:14,icon:e.jsx(re,{className:"h-8 w-8"}),features:[{icon:e.jsx(ae,{className:"h-4 w-4"}),text:"Unlimited donor management"},{icon:e.jsx(ie,{className:"h-4 w-4"}),text:"AI-powered donor matching"},{icon:e.jsx(ne,{className:"h-4 w-4"}),text:"Automated statement generation"},{icon:e.jsx(ce,{className:"h-4 w-4"}),text:"CSV/PDF file imports"},{icon:e.jsx(oe,{className:"h-4 w-4"}),text:"Expense tracking & reports"},{icon:e.jsx(le,{className:"h-4 w-4"}),text:"Multi-user organization access"}],href:"/faith",badge:"New",gradient:"from-purple-500/20 via-indigo-500/10 to-blue-500/20"},{id:"gazelproject",name:"Gazel Project Manager",description:"Plan, schedule, and deliver every project with confidence",price:"$14.99",priceLabel:"/month",trialDays:14,icon:e.jsx(de,{className:"h-8 w-8"}),features:[{icon:e.jsx(ve,{className:"h-4 w-4"}),text:"Hierarchical planning & Gantt views"},{icon:e.jsx(ye,{className:"h-4 w-4"}),text:"Bidirectional Daily Planner sync"},{icon:e.jsx(we,{className:"h-4 w-4"}),text:"Recurring task automation"},{icon:e.jsx(ue,{className:"h-4 w-4"}),text:"Google Calendar integration"},{icon:e.jsx(me,{className:"h-4 w-4"}),text:"Event Planner wizard with AI"},{icon:e.jsx(T,{className:"h-4 w-4"}),text:"Includes ALL Professional plan features"}],href:"/projects",badge:"New",gradient:"from-blue-500/20 via-cyan-500/10 to-teal-500/20"}],Ae=()=>{const{t:l}=H();return e.jsx("section",{className:"mt-16 pt-12 border-t border-border/50",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:l("products.addOnModules","Add-On Modules")}),e.jsx("p",{className:"text-muted-foreground",children:l("products.addOnModulesDescription","Extend your capabilities with specialized modules for your organization")})]}),e.jsx("div",{className:"grid gap-6",children:Pe.map(n=>e.jsxs(U,{className:`relative overflow-hidden border-2 border-purple-200/50 bg-gradient-to-br ${n.gradient} backdrop-blur-sm hover:shadow-lg transition-all duration-300`,children:[n.badge&&e.jsx("div",{className:"absolute top-4 right-4",children:e.jsx("span",{className:"inline-flex items-center px-3 py-1 text-xs font-semibold bg-purple-600 text-white rounded-full",children:n.badge})}),e.jsx(G,{className:"pb-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-xl bg-purple-100 text-purple-600",children:n.icon}),e.jsxs("div",{children:[e.jsx(V,{className:"text-xl",children:n.name}),e.jsx(W,{className:"text-sm mt-1",children:n.description})]})]})}),e.jsx(q,{children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-bold text-foreground",children:n.price}),e.jsx("span",{className:"text-muted-foreground text-sm",children:n.priceLabel})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-50 border border-green-200 rounded-lg w-fit",children:[e.jsx(T,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{className:"text-green-700 text-sm font-medium",children:l("products.dayFreeTrial","{{days}}-day free trial",{days:n.trialDays})})]}),e.jsx(N,{asChild:!0,size:"lg",className:"w-full bg-purple-600 hover:bg-purple-700",children:e.jsx(J,{to:n.href,children:l("products.learnMoreStartTrial","Learn More & Start Trial")})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-3",children:l("products.includedFeatures","Included features:")}),e.jsx("ul",{className:"grid grid-cols-1 gap-2",children:n.features.map((o,p)=>e.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-purple-600",children:o.icon}),e.jsx("span",{children:o.text})]},p))})]})]})})]},n.id))})]})})},Me=()=>{const{isTrialing:l,isSubscribed:n}=pe(),{refetchStatus:o,isLoading:p,error:v,hasPendingSubscription:x,status:t,checkForPendingSubscriptions:u}=I(),{isOnboarding:i,setCurrentStep:f,completeOnboarding:h}=xe(),{toast:g}=R(),m=K(),{t:r}=H(),b=n||l||x||(t==null?void 0:t.subscribed)&&(t==null?void 0:t.pending);d.useEffect(()=>{i&&f("products")},[i,f]),console.log("ProductsPage - Onboarding:",i,"Valid Access:",b,"Status:",t),d.useEffect(()=>{(async()=>{await u(),await o()})()},[u,o]),d.useEffect(()=>{i&&b&&(console.log("User has valid access during onboarding, completing onboarding",{isSubscribed:n,isTrialing:l,hasPendingSubscription:x,statusSub
1scribed:t==null?void 0:t.subscribed,statusPending:t==null?void 0:t.pending}),h(),m("/dashboard",{replace:!0}))},[i,b,n,l,x,t,m,h]);const E=async()=>{try{g({title:r("products.refreshingStatus"),description:r("products.checkingSubscription")}),await u(),await o(),g({title:r("products.statusUpdated"),description:r("products.statusUpdatedDescription")}),console.log("Subscription status refreshed silently")}catch{g({title:r("products.refreshError"),description:r("products.refreshErrorDescription"),variant:"destructive"})}},_=()=>{i&&m("/auth")},y=()=>{h(),m("/dashboard",{replace:!0})},F=()=>{h(),m("/dashboard",{replace:!0}),g({title:r("products.welcomeToGazel"),description:r("products.welcomeDescription")})};return e.jsxs("div",{className:"lovable-no-badge min-h-screen bg-gradient-to-br from-primary/5 via-background to-primary/10 px-4 py-8",children:[i&&e.jsx("div",{className:"container mx-auto max-w-4xl mb-8",children:e.jsx(he,{})}),e.jsxs("div",{className:"container mx-auto px-4",children:[i&&e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs(N,{variant:"ghost",onClick:_,className:"flex items-center gap-2",children:[e.jsx(M,{className:"h-4 w-4"}),r("common.back")]}),e.jsxs("div",{className:"text-right",children:[e.jsx("h2",{className:"text-xl font-semibold text-primary",children:r("products.step3ChoosePlan")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("products.selectPlanOrStart")})]})]}),v&&e.jsxs(k,{variant:"destructive",className:"mb-6",children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsx(P,{children:r("products.subscriptionError")}),e.jsx(A,{children:r("products.subscriptionErrorDescription")})]}),i&&e.jsxs(k,{variant:"default",className:"mb-6 bg-blue-50 border-blue-200",children:[e.jsx(be,{className:"h-4 w-4 text-blue-500"}),e.jsx(P,{className:"text-blue-700",children:r("products.startFreeTrial")}),e.jsxs(A,{className:"text-blue-600 space-y-3",children:[e.jsx("p",{children:r("products.freeTrialDescription")}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(N,{onClick:F,className:"bg-blue-600 hover:bg-blue-700 text-white",children:r("products.startFreeTrialButton")}),e.jsx("span",{className:"text-sm text-blue-500 self-center",children:r("products.orChoosePaid")})]})]})]}),(x||(t==null?void 0:t.subscribed)&&(t==null?void 0:t.pending))&&e.jsxs(k,{variant:"default",className:"mb-6 bg-green-50 border-green-200",children:[e.jsx(T,{className:"h-4 w-4 text-green-500"}),e.jsx(P,{className:"text-green-700",children:r("products.subscriptionActive")}),e.jsxs(A,{className:"text-green-600",children:[r("products.subscriptionActiveDescription"),i&&e.jsx("div",{className:"mt-3",children:e.jsx(N,{onClick:y,className:"bg-green-600 hover:bg-green-700 text-white",children:r("products.continueToFreeTrialDashboard")})})]})]}),i&&b&&e.jsxs(k,{variant:"default",className:"mb-6 bg-blue-50 border-blue-200",children:[e.jsx(T,{className:"h-4 w-4 text-blue-500"}),e.jsx(P,{className:"text-blue-700",children:r("products.readyToContinue")}),e.jsxs(A,{className:"text-blue-600 space-y-3",children:[e.jsx("p",{children:r("products.readyToContinueDescription")}),e.jsx(N,{onClick:y,className:"bg-blue-600 hover:bg-blue-700 text-white",children:r("products.completeSetupButton")})]})]}),e.jsxs("div",{className:"max-w-4xl mx-auto mb-6 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[r("products.smartTaxAnalysisPlans"),e.jsx(Se,{className:"h-5 w-5 text-amber-500"})]})}),e.jsx("p",{className:"text-muted-foreground mb-4",children:r("products.intelligentToolsDescription")}),!i&&e.jsxs(N,{variant:"outline",size:"sm",onClick:E,disabled:p,className:"flex items-center gap-2",children:[e.jsx(fe,{className:`h-4 w-4 ${p?"animate-spin":""}`}),r(p?"products.refreshing":"products.refreshStatus")]})]}),e.jsx(Ae,{}),e.jsx(ke,{}),!i&&e.jsx("div",{className:"max-w-4xl mx-auto mt-8 text-center",children:e.jsxs(J,{to:"/dashboard",onClick:()=>window.scrollTo(0,0),className:"inline-flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(M,{className:"h-4 w-4"}),r("products.backToDashboard")]})})]})]})};export{Me 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.