PageSourceSearch

https://snapio.ai/assets/ManagerEnterpriseAccountsPage-B-dbsrdF.js

js snapio.ai collected 2026-10-05 14:41:04 UTC 25,792 bytes, 6 lines download raw bytes

1import{D as le,F as de,r as P,l as _,ab as y,j as e,G as F,Y as ce,B as p,H as I,J as M,K as U,Z as D,Q as d,v as h,bG as V,b3 as G,C as T,f as w,aq as C,bE as J,e as E,bF as Q,bV as oe,R as me,as as xe,S as pe,a5 as v,ac as ue,W as he,a4 as je,aQ as N,ae as b}from"./index-BSiIgY1-.js";import{T as ge,a as fe,b as W,c as j,d as ye,e as g}from"./table-DMhB0QeS.js";import{U as Z}from"./UserSelector-xUBzzwzG.js";import{P as ve}from"./plus-7p2Vvnv9.js";import{S as Ne}from"./square-pen-C3hywhj6.js";import{P as be}from"./pause-yn4Fu_ZZ.js";import{f as z}from"./format-TOuWWkzE.js";import"./command-D5tefxtn.js";import"./chevrons-up-down-CN5-ch52.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 X=le("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);function Fe(){const{toast:r}=de(),[ee,Y]=P.useState(!1),[n,S]=P.useState(null),[i,A]=P.useState(null),[c,$]=P.useState(null),[t,l]=P.useState({name:"",subscriptionTokens:1e4,initialSeats:5,maxSeats:5,pricePerSeat:"50.00",pricePerToken:"0.10",payAsYouGoEnabled:!1,adminUserId:null}),se=()=>{const s=parseFloat(t.pricePerToken)||0,a=parseFloat(t.pricePerSeat)||0,x=s*t.subscriptionTokens,u=a*t.initialSeats;return x+u},{data:o,isLoading:te}=_({queryKey:["/api/enterprise/accounts"]}),q=(n==null?void 0:n.id)||(i==null?void 0:i.id),{data:m}=_({queryKey:[`/api/enterprise/accounts/${q}/users`,q],enabled:!!q});m!=null&&m.filter(s=>s.role==="enterprise_admin");const O=y({mutationFn:async s=>b("POST","/api/enterprise/accounts",{name:s.name,subscriptionTokens:s.subscriptionTokens,tokenBalance:0,maxSeats:s.initialSeats,pricePerSeat:parseFloat(s.pricePerSeat)||null,pricePerToken:parseFloat(s.pricePerToken)||null,payAsYouGoEnabled:s.payAsYouGoEnabled,adminUserId:s.adminUserId}),onSuccess:()=>{r({title:"Success",description:"Enterprise account created successfully"}),N.invalidateQueries({queryKey:["/api/enterprise/accounts"]}),Y(!1),K()},onError:s=>{r({title:"Error",description:s.message,variant:"destructive"})}}),L=y({mutationFn:async({id:s,data:a})=>b("PATCH",`/api/enterprise/accounts/${s}`,{name:a.name,subscriptionTokens:a.subscriptionTokens,maxSeats:a.maxSeats,pricePerSeat:a.pricePerSeat?parseFloat(a.pricePerSeat):void 0,pricePerToken:a.pricePerToken?parseFloat(a.pricePerToken):void 0,payAsYouGoEnabled:a.payAsYouGoEnabled,adminUserId:a.adminUserId}),onSuccess:()=>{r({title:"Success",description:"Enterprise account updated successfully"}),N.invalidateQueries({queryKey:["/api/enterprise/accounts"]}),S(null),K()},onError:s=>{r({title:"Error",description:s.message,variant:"destructive"})}}),ae=y({mutationFn:async s=>b("DELETE",`/api/enterprise/accounts/${s}`),onSuccess:()=>{r({title:"Success",description:"Enterprise account deleted"}),N.invalidateQueries({queryKey:["/api/enterprise/accounts"]})},onError:s=>{r({title:"Error",description:s.message,variant:"destructive"})}}),ie=y({mutationFn:async s=>b("POST",`/api/enterprise/accounts/${s}/suspend`),onSuccess:()=>{r({title:"Success",description:"Enterprise account suspended"}),N.invalidateQueries({queryKey:["/api/enterprise/accounts"]})},onError:s=>{r({title:"Error",description:s.message,variant:"destructive"})}}),ne=y({mutationFn:async s=>b("POST",`/api/enterprise/accounts/${s}/reactivate`),onSuccess:()=>{r({title:"Success",description:"Enterprise account reactivated"}),N.invalidateQueries({queryKey:["/api/enterprise/accounts"]})},onError:s=>{r({title:"Error",description:s.message,variant:"destructive"})}}),k=y({mutationFn:async({accountId:s,newSeats:a})=>(await b("POST",`/api/enterprise/accounts/${s}/charge-seats`,{newSeats:a})).json(),onSuccess:s=>{s.scheduled?r({title:"Seat Reduction Scheduled",description:s.message}
6):s.charged?r({title:"Seats Updated & Charged",description:`${s.message}. The customer has been charged.`}):r({title:"Seats Updated",description:s.message}),N.invalidateQueries({queryKey:["/api/enterprise/accounts"]}),$(null),S(null),K()},onError:s=>{r({title:"Seat Change Failed",description:s.message,variant:"destructive"})}}),B=y({mutationFn:async s=>(await b("POST",`/api/enterprise/accounts/${s}/cancel-pending-seats`)).json(),onSuccess:()=>{r({title:"Success",description:"Pending seat reduction cancelled"}),N.invalidateQueries({queryKey:["/api/enterprise/accounts"]})},onError:s=>{r({title:"Error",description:s.message,variant:"destructive"})}}),K=()=>{l({name:"",subscriptionTokens:1e4,initialSeats:5,maxSeats:5,pricePerSeat:"50.00",pricePerToken:"0.10",payAsYouGoEnabled:!1,adminUserId:null})},R=s=>{var a,x;l({name:s.name,subscriptionTokens:s.subscriptionTokens,initialSeats:s.maxSeats||5,maxSeats:s.maxSeats||5,pricePerSeat:((a=s.pricePerSeat)==null?void 0:a.toString())||"50.00",pricePerToken:((x=s.pricePerToken)==null?void 0:x.toString())||"0.10",payAsYouGoEnabled:s.payAsYouGoEnabled,adminUserId:null}),S(s)},H=()=>{if(n){const s=n.maxSeats||0,a=t.maxSeats,x=a-s,u=parseFloat(t.pricePerSeat)||0,re=x*u;if(x!==0&&n.status==="active"&&n.polarSubscriptionId){x>0?$({accountId:n.id,accountName:n.name,currentSeats:s,newSeats:a,pricePerSeat:u,chargeAmount:re}):confirm(`Reduce seats from ${s} to ${a}? This will take effect at the end of the billing cycle.`)&&k.mutate({accountId:n.id,newSeats:a});return}L.mutate({id:n.id,data:t})}else O.mutate(t)},f={totalAccounts:(o==null?void 0:o.length)||0,totalUsers:(o==null?void 0:o.reduce((s,a)=>s+(a.userCount||0),0))||0,totalTokensAllocated:(o==null?void 0:o.reduce((s,a)=>s+a.subscriptionTokens,0))||0,activeAccounts:(o==null?void 0:o.filter(s=>s.status==="active").length)||0};return e.jsxs("div",{className:"space-y-6","data-testid":"page-manager-enterprise",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-page-title",children:"Enterprise Accounts"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage enterprise accounts, token pools, and billing settings"})]}),e.jsxs(F,{open:ee,onOpenChange:Y,children:[e.jsx(ce,{asChild:!0,children:e.jsxs(p,{"data-testid":"button-create-enterprise",children:[e.jsx(ve,{className:"h-4 w-4 mr-2"}),"Create Enterprise"]})}),e.jsxs(I,{className:"max-h-[80vh] overflow-y-auto",children:[e.jsxs(M,{children:[e.jsx(U,{children:"Create Enterprise Account"}),e.jsx(D,{children:"Set up a new enterprise account with token pool and pricing"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"name",children:"Enterprise Name"}),e.jsx(h,{id:"name",value:t.name,onChange:s=>l({...t,name:s.target.value}),placeholder:"Acme Corporation","data-testid":"input-enterprise-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"subscriptionTokens",children:"Monthly Token Pool"}),e.jsx(h,{id:"subscriptionTokens",type:"number",value:t.subscriptionTokens,onChange:s=>l({...t,subscriptionTokens:parseInt(s.target.value)||0}),"data-testid":"input-token-pool-size"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"initialSeats",children:"Initial Number of Seats"}),e.jsx(h,{id:"initialSeats",type:"number",min:"1",value:t.initialSeats,onChange:s=>l({...t,initialSeats:parseInt(s.target.value)||1}),"data-testid":"input-initial-seats"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Number of user seats included in the initial subscription"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"pricePerSeat",children:"Price per Seat ($)"}),e.jsx(h,{id:"pricePerSeat",value:t.pricePerSeat,onChange:s=>l({...t,pricePerSeat:s.target.value}),"data-testid":"input-price-per-seat"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"pricePerToken",children:"Price per Overage Token ($)"}),e.jsx(h,{id:"pricePerToken",value:t.pricePerToken,onChange:s=>l({...t,pricePerToken:s.target.value}),"data-testid":"input-token-price"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{htmlFor:"payAsYouGo",children:"Enable Pay-as-you-go (overage billing)"}),e.jsx(V,{id:"payAsYouGo",checked:t.payAsYouGoEnabled,onCheckedChange:s=>l({...t,payAsYouGoEnabled:s}),"data-testid":"switch-pay-as-you-go"})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(d,{htmlFor:"adminUser",children:"Enterprise Admin (Optional)"})]}),e.jsx(Z,{value:t.adminUserId,onValueChange:s=>l({...t,adminUserId:s}),placeholder:"Search and select a user..."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The selected user will be assigned as the enterprise admin with full management access."})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t bg-muted/50 rounded-lg p-4",children:[e.jsx(d,{className:"text-sm font-semibold",children:"Initial Subscription Price"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Tokens (",t.subscriptionTokens.toLocaleStr
6ing()," × $",t.pricePerToken,")"]}),e.jsxs("span",{children:["$",((parseFloat(t.pricePerToken)||0)*t.subscriptionTokens).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Seats (",t.initialSeats," × $",t.pricePerSeat,")"]}),e.jsxs("span",{children:["$",((parseFloat(t.pricePerSeat)||0)*t.initialSeats).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg pt-2 border-t",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{className:"text-primary",children:["$",se().toFixed(2)]})]})]})]})]}),e.jsxs(G,{children:[e.jsx(p,{variant:"outline",onClick:()=>Y(!1),children:"Cancel"}),e.jsx(p,{onClick:H,disabled:O.isPending||!t.name,"data-testid":"button-submit-enterprise",children:O.isPending?"Creating...":"Create Account"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(T,{children:[e.jsxs(w,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"Total Enterprises"}),e.jsx(J,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(E,{children:[e.jsx("div",{className:"text-2xl font-bold",children:f.totalAccounts}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.activeAccounts," active"]})]})]}),e.jsxs(T,{children:[e.jsxs(w,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(E,{children:[e.jsx("div",{className:"text-2xl font-bold",children:f.totalUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all enterprises"})]})]}),e.jsxs(T,{children:[e.jsxs(w,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"Tokens Allocated"}),e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(E,{children:[e.jsx("div",{className:"text-2xl font-bold",children:f.totalTokensAllocated.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total monthly pool"})]})]}),e.jsxs(T,{children:[e.jsxs(w,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"Active Rate"}),e.jsx(me,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(E,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[f.totalAccounts>0?Math.round(f.activeAccounts/f.totalAccounts*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active enterprises"})]})]})]}),e.jsxs(T,{children:[e.jsxs(w,{children:[e.jsx(C,{children:"Enterprise Accounts"}),e.jsx(xe,{children:"All enterprise accounts and their configurations"})]}),e.jsx(E,{children:te?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((s,a)=>e.jsx(pe,{className:"h-16 w-full"},a))}):o&&o.length>0?e.jsxs(ge,{children:[e.jsx(fe,{children:e.jsxs(W,{children:[e.jsx(j,{children:"Enterprise"}),e.jsx(j,{children:"Token Pool"}),e.jsx(j,{children:"Available"}),e.jsx(j,{children:"Seats"}),e.jsx(j,{children:"Users"}),e.jsx(j,{children:"Price/Seat"}),e.jsx(j,{children:"Pay-as-you-go"}),e.jsx(j,{children:"Status"}),e.jsx(j,{children:"Created"}),e.jsx(j,{children:"Actions"})]})}),e.jsx(ye,{children:o.map(s=>e.jsxs(W,{"data-testid":`row-enterprise-${s.id}`,children:[e.jsx(g,{className:"font-medium",children:s.name}),e.jsx(g,{children:s.subscriptionTokens.toLocaleString()}),e.jsx(g,{children:s.tokenBalance.toLocaleString()}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.maxSeats||0}),s.pendingMaxSeats&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(v,{variant:"outline",className:"text-xs bg-yellow-50 text-yellow-700 border-yellow-300",children:["→ ",s.pendingMaxSeats]}),e.jsx(p,{variant:"ghost",size:"sm",className:"h-5 px-1 text-xs text-red-500 hover:text-red-700",onClick:a=>{a.stopPropagation(),confirm(`Cancel the pending seat reduction for ${s.name}?`)&&B.mutate(s.id)},disabled:B.isPending,"data-testid":`button-cancel-pending-seats-${s.id}`,children:"✕"})]})]})}),e.jsx(g,{children:s.userCount||0}),e.jsx(g,{children:s.pricePerSeat?`$${s.pricePerSeat}`:"-"}),e.jsx(g,{children:s.payAsYouGoEnabled?e.jsxs(v,{variant:"default",children:["$",s.pricePerToken||"0.10","/token"]}):e.jsx(v,{variant:"secondary",children:"Disabled"})}),e.jsx(g,{children:e.jsx(v,{variant:s.status==="active"?"default":"destructive",children:s.status})}),e.jsx(g,{className:"text-sm text-muted-foreground",children:z(new Date(s.createdAt),"MMM d, yyyy")}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>A(s),"data-testid":`button-view-enterprise-${s.id}`,children:e.jsx(ue,{className:"h-4 w-4"})}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>R(s),"data-testid":`button-edit-enterprise-${s.id}`,children:e.jsx(Ne,{className:"h-4 w-4"})}),s.status==="active"&&e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>{confirm(`Suspend ${s.name}? Users will lose access to enterprise features.`)&&ie.mutate(s.id)},"data-testid":`button-suspend-enterprise-${s.id}`,children:e.jsx(be,{className:"h-4 w-4 text-yellow-600"})}),s.status==="suspended"&&e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>{confirm(`Reactivate ${s.name}?`)&&ne.mutate(s.id)},"data-testid":`button-reactivate-enterprise-${s.id}`,children:e.jsx(he,{className:"h-4 w-4 text-green-600"})}),e.jsx(p,{variant:"ghost",size:"icon",onClick:()=>{confirm(`Delete ${s.name}? This action cannot be undone.`)&&ae.mutate(s.id)},"data-testid":`button-delete-enterprise-${s.id}`,children:e.jsx(je,{className:"h-4 w-4 text-destructive"})})]})})]},s.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(J,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No enterprise accounts yet"}),e.jsx("p",{className:"text-sm",children:"Create your first enterprise account to get started"})]})})]}),e.jsx(F,{open:!!n,onOpenChange:s=>!s&&S(null),children:e.jsxs(I,{className:"max-h-[80vh] overflow-y-auto",children:[e.jsxs(M,{children:[e.jsx(U,{children:"Edit Enterprise Account"}),e.jsx(D,{children:"Update enterprise settings and token configuration"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-name",children:"Enterprise Name"}),e.jsx(h,{id:"edit-name",value:t.name,onChange:s=>l({...t,name:s.target.value}),"data-testid":"input-edit-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-subscriptionTokens",children:"Monthly Token Pool"}),e.jsx(h,{id:"edit-subscriptionTokens",type:"number",value:t.subscriptionTokens,onChange:s=>l({...t,subscriptionTokens:parseInt(s.target.value)||0}),"data-testid":"input-edit-pool-size"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-maxSeats",children:"Number of Seats"}),e.jsx(h,{id:"edit-maxSeats",type:"number",min:"1",value:t.maxSeats,onChange:s=>l({...t,maxSeats:parseInt(s.target.value)||1}),"data-testid":"input-edit-max-seats"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Number of user seats for this enterprise. Changing this will be billed accordingly."}),(n==null?void 0:n.pendingMaxSeats)&&(n==null?void 0:n.pendingSeatEffectiveAt)&&e.jsx("div",{className:"p-2 bg-yellow-500/10 border border-yellow-500/50 rounded-md",children:e.jsxs("p",{className:"text-xs text-yellow-700 dark:text-yellow-400",children:["Pending change: ",e.jsxs("strong",{children:[n.pendingMaxSeats," seats"]})," scheduled for"," ",z(new Date(n.pendingSeatEffectiveAt),"MMM d, yyyy")]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-pricePerSeat",children:"Price per Seat ($)"}),e.jsx(h,{id:"edit-pricePerSeat",value:t.pricePerSeat,onChange:s=>l({...t,pricePerSeat:s.target.value}),"data-testid":"input-edit-price-seat"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"edit-pricePerToken",children:"Price per Overage Token ($)"}),e.jsx(h,{id:"edit-pricePerToken",value:t.pricePerToken,onChange:s=>l({...t,pricePerToken:s.target.value}),"data-testid":"input-edit-price"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{htmlFor:"edit-payAsYouGo",children:"Enable Pay-as-you-go"}),e.jsx(V,{id:"edit-payAsYouGo",checked:t.payAsYouGoEnabled,onCheckedChange:s=>l({...t,payAsYouGoEnabled:s}),"data-testid":"switch-edit-payg"})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(d,{children:["Current Enterprise Users (",(m==null?void 0:m.length)||0,")"]})]}),m&&m.length>0?e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:m.map(s=>{var a,x,u;return e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted rounded-md",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:(a=s.user)!=null&&a.firstName?`${s.user.firstName}${s.user.lastName?" "+s.user.lastName:""}`:((x=s.user)==null?void 0:x.username)||`User ${s.userId}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u=s.user)==null?void 0:u.email})]}),e.jsx(v,{variant:s.role==="enterprise_admin"?"default":"secondary",children:s.role==="enterprise_admin"?"Admin":"User"})]},s.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No users assigned yet"})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(d,{htmlFor:"edit-adminUser",children:"Add New Admin"})]}),e.jsx(Z,{value:t.adminUserId,onValueChange:s=>l({...t,adminUserId:s}),placeholder:"Search and select a user to add as admin..."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assign a new admin to this enterprise. Existing admins are not affected."})]})]}),e.jsxs(G,{children:[e.jsx(p,{variant:"outline",onClick:()=>S(null),children:"Cancel"}),e.jsx(p,{onClick:H,disabled:L.isPending,"data-testid":"button-save-enterprise",children:L.isPending?"Saving...":"Save Changes"})]})]})}),e.jsx(F,{open:!!i,onOpenChange:s=>!s&&A(null),children:e.jsxs(I,{className:"max-w-2xl",children:[e.jsxs(M,{children:[e.jsx(U,{children:i==null?void 0:i.name}),e.jsx(D,{children:"Enterprise account details and statistics"})]}),i&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Monthly Token Pool"}),e.jsx("p",{className:"text-lg font-semibold",children:i.subscriptionTokens.toLocaleStr
6ing()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Available Tokens"}),e.jsx("p",{className:"text-lg font-semibold",children:i.tokenBalance.toLocaleString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tokens Used"}),e.jsx("p",{className:"text-lg font-semibold",children:(i.subscriptionTokens-i.tokenBalance).toLocaleString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Seats Allocated"}),e.jsx("p",{className:"text-lg font-semibold",children:i.maxSeats||0})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Team Members"}),e.jsx("p",{className:"text-lg font-semibold",children:i.userCount||0})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Price per Seat"}),e.jsx("p",{className:"text-lg font-semibold",children:i.pricePerSeat?`$${i.pricePerSeat}`:"Not set"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pay-as-you-go"}),e.jsx("p",{className:"text-lg font-semibold",children:i.payAsYouGoEnabled?`$${i.pricePerToken||"0.10"}/token`:"Disabled"})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Created"}),e.jsx("span",{children:z(new Date(i.createdAt),"MMMM d, yyyy")})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm mt-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Status"}),e.jsx(v,{variant:i.status==="active"?"default":"destructive",children:i.status})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"font-medium",children:["Enterprise Users (",(m==null?void 0:m.length)||0,")"]})]}),m&&m.length>0?e.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:m.map(s=>{var a,x,u;return e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted rounded-md",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:(a=s.user)!=null&&a.firstName?`${s.user.firstName}${s.user.lastName?" "+s.user.lastName:""}`:((x=s.user)==null?void 0:x.username)||`User ${s.userId}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u=s.user)==null?void 0:u.email})]}),e.jsx(v,{variant:s.role==="enterprise_admin"?"default":"secondary",children:s.role==="enterprise_admin"?"Admin":"User"})]},s.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No users assigned"})]})]}),e.jsxs(G,{children:[e.jsx(p,{variant:"outline",onClick:()=>A(null),children:"Close"}),e.jsx(p,{onClick:()=>{i&&(R(i),A(null))},children:"Edit Account"})]})]})}),e.jsx(F,{open:!!c,onOpenChange:s=>!s&&$(null),children:e.jsxs(I,{"data-testid":"dialog-seat-confirmation",children:[e.jsxs(M,{children:[e.jsx(U,{children:"Confirm Seat Change"}),e.jsxs(D,{children:["You are about to add seats to ",c==null?void 0:c.accountName,". This will charge the customer automatically."]})]}),c&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"p-4 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Current Seats"}),e.jsx("span",{className:"font-medium",children:c.currentSeats})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"New Seats"}),e.jsx("span",{className:"font-medium",children:c.newSeats})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Seats Added"}),e.jsxs("span",{className:"font-medium text-primary",children:["+",c.newSeats-c.currentSeats]})]}),e.jsxs("div",{className:"flex justify-between border-t pt-3",children:[e.jsx("span",{className:"text-muted-foreground",children:"Price per Seat"}),e.jsxs("span",{className:"font-medium",children:["$",c.pricePerSeat.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-lg font-bold",children:[e.jsx("span",{children:"Total Charge"}),e.jsxs("span",{className:"text-primary",children:["$",c.chargeAmount.toFixed(2)]})]})]}),e.jsx("div",{className:"p-3 bg-yellow-500/10 border border-yellow-500/50 rounded-lg",children:e.jsxs("p",{className:"text-sm text-yellow-700 dark:text-yellow-400",children:[e.jsx("strong",{children:"Important:"})," The customer will be charged $",c.chargeAmount.toFixed(2)," using their payment method on file."]})})]}),e.jsxs(G,{children:[e.jsx(p,{variant:"outline",onClick:()=>$(null),disabled:k.isPending,children:"Cancel"}),e.jsx(p,{onClick:()=>{c&&k.mutate({accountId:c.accountId,newSeats:c.newSeats})},disabled:k.isPending,"data-testid":"button-confirm-seat-charge",children:k.isPending?"Processing...":"Confirm & Charge Customer"})]})]})})]})}export{Fe 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.