1import{r as i,j as e,b as j}from"./vendor-RrrBg8En.js";import{a as N,u as f}from"./index-BApPt7ad.js";import{w as v}from"./withAuth-BO9KnnGW.js";const d=j(),C=()=>{const[m,u]=i.useState([]),[p,x]=i.useState(!0),[s,a]=i.useState({id:"",displayName:"",seatCount:15,stripePriceIdMonthly:"",stripePriceIdAnnual:"",monthlyPrice:0,yearlyPrice:0,allowedDomains:"",description:""}),{toast:r}=N();i.useEffect(()=>{n()},[]);const n=async()=>{try{const t=await d.models.CustomPricingConfig.list();console.log("Loaded configs:",t),u(t.data||[])}catch(t){console.error("Error loading configs:",t)}finally{x(!1)}},h=async t=>{t.preventDefault();try{const b=(await f.getUserAttributes()).attributes.email||"",c=s.allowedDomains.split(",").map(o=>o.trim().toLowerCase()).filter(o=>o.length>0);c.includes("ycj-group.com")||c.push("ycj-group.com"),await d.models.CustomPricingConfig.create({id:s.id,displayName:s.displayName,seatCount:s.seatCount,stripePriceIdMonthly:s.stripePriceIdMonthly,stripePriceIdAnnual:s.stripePriceIdAnnual,monthlyPrice:s.monthlyPrice,yearlyPrice:s.yearlyPrice,allowedDomains:c,description:s.description,planType:"ENTERPRISE",isActive:!0,currency:"usd",createdBy:b,createdAt:new Date().toISOString(),usageCount:0}),r({title:"Success",description:"Config created successfully"}),a({id:"",displayName:"",seatCount:15,stripePriceIdMonthly:"",stripePriceIdAnnual:"",monthlyPrice:0,yearlyPrice:0,allowedDomains:"",description:""}),n()}catch{r({title:"Error",description:"Failed to create config",variant:"destructive"})}},y=t=>{const l=`${window.location.origin}/dashboard/pricing/${t}`;navigator.clipboard.writeText(l),r({title:"Copied!",description:"URL copied to clipboard"})},g=async t=>{try{await d.models.CustomPricingConfig.update({id:t.id,isActive:!t.isActive}),n(),r({title:"Success",description:"Status updated"})}catch{r({title:"Error",description:"Failed to update",variant:"destructive"})}};return e.jsxs("div",{className:"p-8 max-w-7xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold mb-8",children:"Custom Pricing Manager"}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6 mb-8",children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Create New Config"}),e.jsxs("form",{onSubmit:h,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"ID (URL slug)"}),e.jsx("input",{type:"text",value:s.id,onChange:t=>a({...s,id:t.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")}),className:"w-full border rounded px-3 py-2",placeholder:"acme-corp-50-seats",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Display Name"}),e.jsx("input",{type:"text",value:s.displayName,onChange:t=>a({...s,displayName:t.target.value}),className:"w-full border rounded px-3 py-2",placeholder:"Acme Corp Enterprise",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Seat Count"}),e.jsx("input",{type:"number",value:s.seatCount,onChange:t=>a({...s,seatCount:parseInt(t.target.value)}),className:"w-full border rounded px-3 py-2",min:"10",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Monthly Stripe Price ID"}),e.jsx("input",{type:"text",value:s.stripePriceIdMonthly,onChange:t=>a({...s,stripePriceIdMonthly:t.target.value}),className:"w-full border rounded px-3 py-2",placeholder:"price_xxxxx",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Annual Stripe Price ID"}),e.jsx("input",{type:"text",value:s.stripePriceIdAnnual,onChange:t=>a({...s,stripePriceIdAnnual:t.target.value}),className:"w-full border rounded px-3 py-2",placeholder:"price_yyyyy",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Monthly Price (USD)"}),e.jsx("input",{type:"number",step:"0.01",value:s.monthlyPrice,onChange:t=>a({...s,monthlyPrice:parseFloat(t.target.value)}),className:"w-full border rounded px-3 py-2",placeholder:"999.00",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Yearly Price (USD)"}),e.jsx("input",{type:"number",step:"0.01",value:s.yearlyPrice,onChange:t=>a({...s,yearlyPrice:parseFloat(t.target.value)}),className:"w-full border rounded px-3 py-2",placeholder:"9999.00",required:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Allowed Email Domains"}),e.jsx("input",{type:"text",value:s.allowedDomains,onChange:t=>a({...s,allowedDomains:t.target.value}),className:"w-full border rounded px-3 py-2",placeholder:"acme.com, example.com (ycj-group.com auto-included)",required:!0}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Comma-separated. ycj-group.com is always included."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Description (Optional)"}),e.jsx("textarea",{value:s.description,onChange:t=>a({...s,description:t.target.value}),className:"w-full border rounded px-3 py-2",rows:3})]}),e.jsx("button",{type:"submit",className:"bg-gray-900 text-white px-6 py-2 rounded hover:bg-gray-800",children:"Create Config"})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow",children:[e.jsx("h2",{className:"text-xl font-semibold p-6 border-b",children:"Existing Configs"}),p?e.jsx("p",{className:"p-6",children:"Loading..."}):m.length===0?e.jsx("p",{className:"p-6 text-gray-500",children:"No configs yet"}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",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:"ID"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Display Name"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Seats"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Usage"}),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:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:m.map(t=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 text-sm font-mono",children:t.id}),e.jsx("td",{className:"px-6 py-4 text-sm",children:t.displayName}),e.jsx("td",{className:"px-6 py-4 text-sm",children:t.seatCount}),e.jsx("td",{className:"px-6 py-4 text-sm",children:t.usageCount||0}),e.jsx("td",{className:"px-6 py-4 text-sm",children:e.jsx("span",{className:`px-2 py-1 rounded text-xs ${t.isActive?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:t.isActive?"Active":"Inactive"})}),e.jsxs("td",{className:"px-6 py-4 text-sm space-x-2",children:[e.jsx("button",{onClick:()=>y(t.id),className:"text-blue-600 hover:underline",children:"Copy URL"}),e.jsx("button",{onClick:()=>g(t),className:"text-gray-600 hover:underline",children:"Toggle"})]})]},t.id))})]})})]})]})},D=v(C,{requireAuth:!0,requireCompletedOnboarding:!0});export{D 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.