PageSourceSearch

https://slickbot.ai/assets/PlansPage-CSpMTyVR.js

js slickbot.ai collected 2026-10-05 14:28:47 UTC 14,986 bytes, 1 lines download raw bytes

1import{d as M,u as q,b as u,j as e}from"./vendor-query-DPZO-Gta.js";import{r as n}from"./vendor-react-BomFe3BT.js";import{R as I,Y as o,z as i}from"./index-BLzMsaFd.js";import{F as E}from"./PlusIcon-nEEzp82l.js";import{F as A}from"./XMarkIcon-C0QMP-E_.js";import{F as z}from"./PencilIcon-TEIfEoRi.js";import{F as R}from"./TrashIcon-DwIhsXGs.js";import"./vendor-charts-DodUWJ0z.js";function $({title:c,titleId:x,...m},d){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:d,"aria-labelledby":x},m),c?n.createElement("title",{id:x},c):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"}))}const D=n.forwardRef($),y={name:"",slug:"",description:"",price_monthly:0,price_yearly:0,max_chatbots:1,max_messages_per_month:100,max_documents_per_chatbot:5,max_document_size_mb:10,has_api_access:!1,has_analytics:!1,has_custom_branding:!1,has_priority_support:!1,has_calendar_integration:!1,has_team_features:!1,max_team_members:1,has_voice_calls:!1,has_phone_calls:!1,max_voice_minutes_per_month:0,max_phone_numbers:0,is_active:!0,is_public:!0,sort_order:0};function Y(){const c=M(),[x,m]=n.useState(!1),[d,h]=n.useState(null),[a,t]=n.useState(y),[_,w]=n.useState(!1),{data:g,isLoading:C}=q({queryKey:["admin-plans",_],queryFn:()=>o.listPlans(_)}),b=u({mutationFn:s=>o.createPlan(s),onSuccess:()=>{i.success("Plan created"),c.invalidateQueries({queryKey:["admin-plans"]}),p()},onError:s=>{var r,l;i.error(((l=(r=s.response)==null?void 0:r.data)==null?void 0:l.detail)||"Failed to create plan")}}),j=u({mutationFn:({id:s,data:r})=>o.updatePlan(s,r),onSuccess:()=>{i.success("Plan updated"),c.invalidateQueries({queryKey:["admin-plans"]}),p()},onError:s=>{var r,l;i.error(((l=(r=s.response)==null?void 0:r.data)==null?void 0:l.detail)||"Failed to update plan")}}),k=u({mutationFn:s=>o.deletePlan(s),onSuccess:()=>{i.success("Plan deleted"),c.invalidateQueries({queryKey:["admin-plans"]})},onError:s=>{var r,l;i.error(((l=(r=s.response)==null?void 0:r.data)==null?void 0:l.detail)||"Failed to delete plan")}}),N=u({mutationFn:s=>o.syncPlanToStripe(s),onSuccess:()=>{i.success("Plan synced to Stripe"),c.invalidateQueries({queryKey:["admin-plans"]})},onError:s=>{var r,l;i.error(((l=(r=s.response)==null?void 0:r.data)==null?void 0:l.detail)||"Failed to sync to Stripe")}}),v=(g==null?void 0:g.data)||[],P=()=>{h(null),t(y),m(!0)},F=s=>{h(s),t({name:s.name,slug:s.slug,description:s.description||"",price_monthly:parseFloat(s.price_monthly),price_yearly:parseFloat(s.price_yearly),max_chatbots:s.max_chatbots,max_messages_per_month:s.max_messages_per_month,max_documents_per_chatbot:s.max_documents_per_chatbot,max_document_size_mb:s.max_document_size_mb,has_api_access:s.has_api_access,has_analytics:s.has_analytics,has_custom_branding:s.has_custom_branding,has_priority_support:s.has_priority_support,has_calendar_integration:s.has_calendar_integration,has_team_features:s.has_team_features,max_team_members:s.max_team_members,has_voice_calls:s.has_voice_calls,has_phone_calls:s.has_phone_calls,max_voice_minutes_per_month:s.max_voice_minutes_per_month,max_phone_numbers:s.max_phone_numbers,is_active:s.is_active,is_public:s.is_public,sort_order:s.sort_order}),m(!0)},p=()=>{m(!1),h(null),t(y)},S=s=>{s.preventDefault(),d?j.mutate({id:d.id,data:a}):b.mutate(a)},f=s=>s===-1?"Unlimited":s.toLocaleString();return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Subscription Plans"}),e.jsx("p",{className:"text-gray-500",children:"Manage subscription plans and pricing"})]}),e.jsxs("button",{onClick:P,className:"btn-primary flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5"}),"Add Plan"]})]}),e.jsx("div",{className:"mb-4",children:e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:s=>w(s.target.checked),className:"rounded border-gray-300"}),e.jsx("span",{className:"text-sm text-gray-600",children:"Show inactive plans"})]})}),e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Plan"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Pricing"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Limits"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Features"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Stripe"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:C?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-8 text-center text-gray-500",children:"Loading..."})}):v.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-8 text-center text-gray-500",children:"No plans found"})}):v.map(s=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:s.name}),e.jsx("p",{className:"text-sm text-gray-500",children:s.slug})]})}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsxs("p",{className:"text-sm",children:["$",parseFloat(s.price_monthly).toFixed(2),"/mo"]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["$",parseFloat(s.price_yearly).toFixed(2),"/yr"]})]}),e.jsxs("td",{className:"px-6 py-4 text-sm",children:[e.jsxs("p",{children:[f(s.max_chatbots)," bots"]}),e.jsxs("p",{className:"text-gray-500",children:[f(s.max_messages_per_month)," msgs/mo"]})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.has_api_access&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded",children:"API"}),s.has_analytics&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-green-100 text-green-700 rounded",children:"Analytics"}),s.has_calendar_integration&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-purple-100 text-purple-700 rounded",children:"Calendar"}),s.has_team_features&&e.jsxs("span",{className:"px-2 py-0.5 text-xs bg-orange-100 text-orange-700 rounded",children:["Team (",s.max_team_members===-1?"∞":s.max_team_members,")"]}),s.has_voice_calls&&e.jsxs("span",{className:"px-2 py-0.5 text-xs bg-indigo-100 text-indigo-700 rounded",children:["Voice (",s.max_voice_minutes_per_month===-1?"∞":s.max_voice_minutes_per_month," min)"]}),s.has_phone_calls&&e.jsxs("span",{className:"px-2 py-0.5 text-xs bg-pink-100 text-pink-700 rounded",children:["Phone (",s.max_phone_numbers===-1?"∞":s.max_ph
1one_numbers," #s)"]})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[s.is_active?e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-xs bg-green-100 text-green-700 rounded",children:"Active"}):e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-xs bg-gray-100 text-gray-700 rounded",children:"Inactive"}),s.is_public?e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded",children:"Public"}):e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 text-xs bg-yellow-100 text-yellow-700 rounded",children:"Hidden"})]})}),e.jsx("td",{className:"px-6 py-4",children:s.stripe_product_id?e.jsx(I,{className:"h-5 w-5 text-green-500",title:"Synced"}):e.jsx(A,{className:"h-5 w-5 text-gray-300",title:"Not synced"})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>N.mutate(s.id),className:"p-1 text-gray-400 hover:text-blue-600",title:"Sync to Stripe",disabled:N.isPending,children:e.jsx(D,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>F(s),className:"p-1 text-gray-400 hover:text-gray-600",title:"Edit",children:e.jsx(z,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>{confirm("Are you sure you want to delete this plan?")&&k.mutate(s.id)},className:"p-1 text-gray-400 hover:text-red-600",title:"Delete",children:e.jsx(R,{className:"h-5 w-5"})})]})})]},s.id))})]})}),x&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:p}),e.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto m-4",children:[e.jsx("div",{className:"px-6 py-4 border-b",children:e.jsx("h2",{className:"text-lg font-semibold",children:d?"Edit Plan":"Create Plan"})}),e.jsxs("form",{onSubmit:S,className:"p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Name"}),e.jsx("input",{type:"text",value:a.name,onChange:s=>t({...a,name:s.target.value}),className:"input",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Slug"}),e.jsx("input",{type:"text",value:a.slug,onChange:s=>t({...a,slug:s.target.value}),className:"input",required:!0,disabled:!!d})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Description"}),e.jsx("textarea",{value:a.description,onChange:s=>t({...a,description:s.target.value}),className:"input",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Monthly Price ($)"}),e.jsx("input",{type:"number",step:"0.01",value:a.price_monthly,onChange:s=>t({...a,price_monthly:parseFloat(s.target.value)}),className:"input",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Yearly Price ($)"}),e.jsx("input",{type:"number",step:"0.01",value:a.price_yearly,onChange:s=>t({...a,price_yearly:parseFloat(s.target.value)}),className:"input",required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Chatbots (-1 = unlimited)"}),e.jsx("input",{type:"number",value:a.max_chatbots,onChange:s=>t({...a,max_chatbots:parseInt(s.target.value)}),className:"input",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Messages/Month (-1 = unlimited)"}),e.jsx("input",{type:"number",value:a.max_messages_per_month,onChange:s=>t({...a,max_messages_per_month:parseInt(s.target.value)}),className:"input",required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Docs/Chatbot"}),e.jsx("input",{type:"number",value:a.max_documents_per_chatbot,onChange:s=>t({...a,max_documents_per_chatbot:parseInt(s.target.value)}),className:"input",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Doc Size (MB)"}),e.jsx("input",{type:"number",value:a.max_document_size_mb,onCh
1ange:s=>t({...a,max_document_size_mb:parseInt(s.target.value)}),className:"input",required:!0})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Sort Order"}),e.jsx("input",{type:"number",value:a.sort_order,onChange:s=>t({...a,sort_order:parseInt(s.target.value)}),className:"input"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"label",children:"Features"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{key:"has_api_access",label:"API Access"},{key:"has_analytics",label:"Analytics"},{key:"has_custom_branding",label:"Custom Branding"},{key:"has_priority_support",label:"Priority Support"},{key:"has_calendar_integration",label:"Calendar Integration"},{key:"has_team_features",label:"Team Features"},{key:"has_voice_calls",label:"Voice Calls"},{key:"has_phone_calls",label:"Phone Calls"}].map(s=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:a[s.key],onChange:r=>t({...a,[s.key]:r.target.checked}),className:"rounded border-gray-300"}),e.jsx("span",{className:"text-sm",children:s.label})]},s.key))})]}),a.has_team_features&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Team Members (-1 = unlimited)"}),e.jsx("input",{type:"number",value:a.max_team_members,onChange:s=>t({...a,max_team_members:parseInt(s.target.value)}),className:"input",min:"-1"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Number of members allowed per organization when this plan is active"})]}),a.has_voice_calls&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Voice Minutes/Month (-1 = unlimited)"}),e.jsx("input",{type:"number",value:a.max_voice_minutes_per_month,onChange:s=>t({...a,max_voice_minutes_per_month:parseInt(s.target.value)}),className:"input",min:"-1"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Total voice call minutes allowed per month"})]}),a.has_phone_calls&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Max Phone Numbers (-1 = unlimited)"}),e.jsx("input",{type:"number",value:a.max_phone_numbers,onChange:s=>t({...a,max_phone_numbers:parseInt(s.target.value)}),className:"input",min:"-1"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Maximum phone numbers the user can provision"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"label",children:"Status"}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:a.is_active,onChange:s=>t({...a,is_active:s.target.checked}),className:"rounded border-gray-300"}),e.jsx("span",{className:"text-sm",children:"Active"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:a.is_public,onChange:s=>t({...a,is_public:s.target.checked}),className:"rounded border-gray-300"}),e.jsx("span",{className:"text-sm",children:"Public (show on pricing page)"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx("button",{type:"button",onClick:p,className:"btn-secondary",children:"Cancel"}),e.jsx("button",{type:"submit",className:"btn-primary",disabled:b.isPending||j.isPending,children:d?"Update":"Create"})]})]})]})]})]})}export{Y 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.