1import{c as $,N as I,r as h,d as K,j as e,L as M,n,e as L,h as P,B as g,R as G,I as m,aa as o,Q as w}from"./index-CgaGlvxl.js";import{u as S}from"./useMutation-CwBo1lBR.js";import{u as Y}from"./useAuth-CV1dEo_h.js";import{D as R,a as U,b as H,c as W,d as J,f as X}from"./dialog-BwXpTk5Z.js";import{L as r}from"./label-DblMUqIL.js";import{S as E}from"./switch-Cy8vJVlG.js";import{S as Z,a as _,b as ee,c as se,d as ae}from"./select-A_Awahjj.js";import{A as te}from"./arrow-left-BP-rkUH3.js";import{P as T}from"./plus-CX3H_0Xl.js";import{S as ie}from"./star-D9gZfgk_.js";import{P as re}from"./pencil-ClXQhFNg.js";import{T as ne}from"./trash-2-BWD8Qr7u.js";import"./index-B4dzTveH.js";import"./index-NjcTnB8j.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const le=$("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),C=[{value:"platinum",label:"Platinum (Dark Gray)"},{value:"gold",label:"Gold (Yellow)"},{value:"silver",label:"Silver (Light Gray)"},{value:"bronze",label:"Bronze (Orange)"},{value:"purple",label:"Purple"},{value:"blue",label:"Blue"},{value:"green",label:"Green"},{value:"pink",label:"Pink"}],f={platinum:"bg-gradient-to-br from-gray-700 to-gray-900",gold:"bg-gradient-to-br from-yellow-600 to-yellow-800",silver:"bg-gradient-to-br from-gray-300 to-gray-500",bronze:"bg-gradient-to-br from-orange-700 to-orange-900",purple:"bg-gradient-to-br from-purple-600 to-purple-900",blue:"bg-gradient-to-br from-blue-600 to-blue-900",green:"bg-gradient-to-br from-green-600 to-green-900",pink:"bg-gradient-to-br from-pink-500 to-pink-800"};function ce(i){return i?f[i]?f[i]:i.startsWith("bg-")?i:f.platinum:f.platinum}function we(){const{toast:i}=I(),{isAuthenticated:b,isLoading:j}=Y(),[O,l]=h.useState(!1),[a,p]=h.useState(null),[k,c]=h.useState("");h.useEffect(()=>{!j&&!b&&(i({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{window.location.href="/admin/login"},500))},[b,j,i]);const{data:F=[],isLoading:q}=K({queryKey:["/api/admin/pricing-packages"]}),v=S({mutationFn:async s=>await w("POST","/api/admin/pricing-packages",s),onSuccess:()=>{o.invalidateQueries({queryKey:["/api/admin/pricing-packages"]}),o.invalidateQueries({queryKey:["/api/pricing-packages"]}),l(!1),c(""),i({title:"Success",description:"Pricing package created successfully"})},onError:s=>{i({title:"Error",description:s.message,variant:"destructive"})}}),y=S({mutationFn:async({id:s,data:t})=>await w("PATCH",`/api/admin/pricing-packages/${s}`,t),onSuccess:()=>{o.invalidateQueries({queryKey:["/api/admin/pricing-packages"]}),o.invalidateQueries({queryKey:["/api/pricing-packages"]}),l(!1),p(null),c(""),i({title:"Success",description:"Pricing package updated successfully"})},onError:s=>{i({title:"Error",description:s.message,variant:"destructive"})}}),V=S({mutationFn:async s=>await w("DELETE",`/api/admin/pricing-packages/${s}`),onSuccess:()=>{o.invalidateQueries({queryKey:["/api/admin/pricing-packages"]}),o.invalidateQueries({queryKey:["/api/pricing-packages"]}),i({title:"Success",description:"Pricing package deleted successfully"})},onError:s=>{i({title:"Error",description:s.message,variant:"destructive"})}}),z=s=>{s.preventDefault();const t=new FormData(s.currentTarget),x=k.split(` 7`).map(d=>d.trim()).filter(d=>d.length>0),u={name:t.get("name"),subtitle:t.get("subtitle")||null,price:t.get("price"),period:t.get("period")||"/Year",colorClass:t.get("colorClass")||C[0].value,benefits:x,sortOrder:parseInt(t.get("sortOrder"))||0,isFeatured:t.get("isFeatured")==="on",isActive:t.get("isActive")==="on"};a?y.mutate({id:a.id,data:u}):v.mutate(u)},B=s=>{var t;p(s),c(((t=s.benefits)==null?void 0:t.join(` 8`))||""),l(!0)},A=()=>{p(null),c(""),l(!0)};return j?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-primary border-t-transparent roun
8ded-full mx-auto mb-4"}),e.jsx("p",{children:"Loading..."})]})}):b?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(M,{href:"/admin",children:e.jsx(n,{variant:"outline",size:"icon","data-testid":"button-back",children:e.jsx(te,{className:"h-4 w-4"})})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Pricing Packages"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage corporate membership pricing tiers and benefits"})]})]}),e.jsxs(n,{onClick:A,"data-testid":"button-add-package",children:[e.jsx(T,{className:"h-4 w-4 mr-2"}),"Add Package"]})]}),q?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-primary border-t-transparent rounded-full mx-auto mb-4"}),e.jsx("p",{children:"Loading pricing packages..."})]}):F.length===0?e.jsx(L,{children:e.jsxs(P,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No pricing packages yet"}),e.jsxs(n,{onClick:A,"data-testid":"button-create-first",children:[e.jsx(T,{className:"h-4 w-4 mr-2"}),"Create First Package"]})]})}):e.jsx("div",{className:"grid gap-6",children:F.map((s,t)=>{var x,u,d,D;return e.jsx(L,{className:s.isActive?"":"opacity-60","data-testid":`card-package-${t}`,children:e.jsx(P,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5"}),e.jsxs("span",{className:"text-sm font-medium",children:["#",s.sortOrder]})]}),e.jsx("div",{className:`w-16 h-16 rounded-lg ${ce(s.colorClass)} flex items-center justify-center text-white`,children:e.jsx("span",{className:"text-xs font-bold text-center px-1",children:(x=s.name)==null?void 0:x.split(" ")[0]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:s.name}),s.isFeatured&&e.jsxs(g,{variant:"default",className:"text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Featured"]}),!s.isActive&&e.jsx(g,{variant:"secondary",className:"text-xs",children:"Inactive"})]}),s.subtitle&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:s.subtitle}),e.jsxs("div",{className:"flex items-baseline gap-1 mb-3",children:[e.jsx("span",{className:"text-2xl font-bold text-primary",children:s.price}),e.jsx("span",{className:"text-muted-foreground",children:s.period})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(u=s.benefits)==null?void 0:u.slice(0,4).map((N,Q)=>e.jsxs(g,{variant:"outline",className:"text-xs",children:[e.jsx(G,{className:"h-3 w-3 mr-1"}),N.length>30?N.substring(0,30)+"...":N]},Q)),(((d=s.benefits)==null?void 0:d.length)||0)>4&&e.jsxs(g,{variant:"secondary",className:"text-xs",children:["+",(((D=s.benefits)==null?void 0:D.length)||0)-4," more"]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(n,{variant:"outline",size:"icon",onClick:()=>B(s),"data-testid":`button-edit-${t}`,children:e.jsx(re,{className:"h-4 w-4"})}),e.jsx(n,{variant:"outline",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this pricing package?")&&V.mutate(s.id)},"data-testid":`button-delete-${t}`,children:e.jsx(ne,{className:"h-4 w-4"})})]})]})})},s.id)})}),e.jsx(R,{open:O,onOpenChange:l,children:e.jsxs(U,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(H,{
8children:[e.jsx(W,{children:a?"Edit Pricing Package":"Create Pricing Package"}),e.jsx(J,{children:a?"Update the pricing package details and benefits":"Add a new pricing tier for corporate memberships"})]}),e.jsxs("form",{onSubmit:z,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"name",children:"Package Name *"}),e.jsx(m,{id:"name",name:"name",defaultValue:(a==null?void 0:a.name)||"",placeholder:"e.g., Platinum Level",required:!0,"data-testid":"input-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"subtitle",children:"Subtitle"}),e.jsx(m,{id:"subtitle",name:"subtitle",defaultValue:(a==null?void 0:a.subtitle)||"",placeholder:"e.g., Membership","data-testid":"input-subtitle"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"price",children:"Price *"}),e.jsx(m,{id:"price",name:"price",defaultValue:(a==null?void 0:a.price)||"",placeholder:"e.g., $4000+",required:!0,"data-testid":"input-price"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"period",children:"Period"}),e.jsx(m,{id:"period",name:"period",defaultValue:(a==null?void 0:a.period)||"/Year",placeholder:"e.g., /Year","data-testid":"input-period"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"colorClass",children:"Color Theme"}),e.jsxs(Z,{name:"colorClass",defaultValue:(a==null?void 0:a.colorClass)||C[0].value,children:[e.jsx(_,{"data-testid":"select-color",children:e.jsx(ee,{placeholder:"Select a color"})}),e.jsx(se,{children:C.map(s=>e.jsx(ae,{value:s.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-4 h-4 rounded ${s.value}`}),s.label]})},s.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"sortOrder",children:"Sort Order"}),e.jsx(m,{id:"sortOrder",name:"sortOrder",type:"number",defaultValue:(a==null?void 0:a.sortOrder)||0,placeholder:"0","data-testid":"input-sort-order"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Lower numbers appear first"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"benefits",children:"Benefits (one per line) *"}
8),e.jsx("textarea",{id:"benefits",value:k,onChange:s=>c(s.target.value),className:"flex min-h-[150px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:`Logo and link to your website 9Recognition on our social media 10Sponsorship opportunities 11...`,required:!0,"data-testid":"textarea-benefits"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter each benefit on a new line. These will appear as bullet points on the pricing page."})]}),e.jsxs("div",{className:"flex gap-8",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{id:"isFeatured",name:"isFeatured",defaultChecked:(a==null?void 0:a.isFeatured)||!1,"data-testid":"switch-featured"}),e.jsx(r,{htmlFor:"isFeatured",children:"Featured (Best Value badge)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{id:"isActive",name:"isActive",defaultChecked:(a==null?void 0:a.isActive)!==!1,"data-testid":"switch-active"}),e.jsx(r,{htmlFor:"isActive",children:"Active (visible on website)"})]})]})]}),e.jsxs(X,{children:[e.jsx(n,{type:"button",variant:"outline",onClick:()=>{l(!1),p(null),c("")},"data-testid":"button-cancel",children:"Cancel"}),e.jsx(n,{type:"submit",disabled:v.isPending||y.isPending,"data-testid":"button-submit",children:v.isPending||y.isPending?"Saving...":a?"Update Package":"Create Package"})]})]})]})})]})}):null}export{we 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.