2 lines
3.3 KiB
JavaScript
2 lines
3.3 KiB
JavaScript
import{r as d,j as t}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{u as p,T as _,P as y}from"./main-af3pcbZa.js";import{P}from"./PricingTable-DY2_-9tK.js";const a=e=>e.toLocaleString(),j=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:e.toString(),$=e=>{const s=[];if(s.push(`${e.max_sites} ${e.max_sites===1?"Site":"Sites"}`),s.push(`${e.max_users} ${e.max_users===1?"User":"Users"}`),s.push(`${a(e.max_keywords)} Keywords`),s.push(`${a(e.max_clusters)} Clusters`),s.push(`${a(e.max_content_ideas)} Content Ideas`),s.push(`${j(e.monthly_word_count_limit)} Words/Month`),s.push(`${e.daily_content_tasks} Daily Content Tasks`),s.push(`${e.monthly_image_count} Images/Month`),e.image_model_choices&&e.image_model_choices.length>0){const n=e.image_model_choices.map(i=>i.toUpperCase()).join(", ");s.push(`${n} Image Models`)}return s.push(`${a(e.included_credits)} AI Credits Included`),s.push(`${a(e.monthly_ai_credit_limit)} Monthly AI Credit Limit`),e.features&&Array.isArray(e.features)&&(e.features.includes("ai_writer")&&s.push("AI Writer"),e.features.includes("image_gen")&&s.push("Image Generation"),e.features.includes("auto_publish")&&s.push("Auto Publish"),e.features.includes("custom_prompts")&&s.push("Custom Prompts")),s},N=(e,s,n)=>{const i=typeof e.price=="number"?e.price:parseFloat(String(e.price||0)),c=e.slug.toLowerCase()==="growth";return{id:e.id,name:e.name,monthlyPrice:i,price:i,period:"/month",description:v(e),features:$(e),buttonText:"Choose Plan",highlighted:c}},v=e=>{const s=e.slug.toLowerCase();return s.includes("free")?"Perfect for getting started":s.includes("starter")?"For solo designers & freelancers":s.includes("growth")?"For growing businesses":s.includes("scale")||s.includes("enterprise")?"For teams and large organizations":"Choose the perfect plan for your needs"};function S(){const e=p(),[s,n]=d.useState([]),[i,c]=d.useState(!0);d.useEffect(()=>{h()},[]);const h=async()=>{try{c(!0);const l=((await _("/v1/auth/plans/")).results||[]).filter(o=>o.is_active).sort((o,u)=>{const g=typeof o.price=="number"?o.price:parseFloat(String(o.price||0)),x=typeof u.price=="number"?u.price:parseFloat(String(u.price||0));return g-x});n(l)}catch(r){e.error(`Failed to load plans: ${r.message}`)}finally{c(!1)}},f=r=>{console.log("Selected plan:",r),e.success(`Selected plan: ${r.name}`)},m=s.map((r,l)=>N(r,l,s.length));return t.jsxs("div",{className:"p-6",children:[t.jsx(y,{title:"Plans"}),t.jsxs("div",{className:"mb-6",children:[t.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Plans"}),t.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Choose the perfect plan for your needs. All plans include our core features."})]}),i?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx("div",{className:"text-gray-500",children:"Loading plans..."})}):m.length===0?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx("div",{className:"text-gray-500",children:"No active plans available"})}):t.jsxs(t.Fragment,{children:[t.jsx(P,{variant:"1",title:"Flexible Plans Tailored to Fit Your Unique Needs!",plans:m,showToggle:!0,onPlanSelect:f}),t.jsx("div",{className:"mt-8 text-center",children:t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Need more details? View all features and limits for each plan."})})]})]})}export{S as default};
|