PageSourceSearch

https://repsshield.com/assets/organization-admin-XhFMe27z.js

js repsshield.com collected 2026-10-02 02:01:57 UTC 14,056 bytes, 6 lines download raw bytes

1import{z as X,p as Z,a as ee,aM as se,r as v,aE as U,aG as T,j as e,C as c,b as m,c as x,x as F,aS as u,d as h,e as g,k as ae,G as ie,I as re,J as y,U as ne,au as te,bN as le,K as N,a0 as E,a1 as B,a2 as A,a3 as M,a4 as p,b1 as q,bM as z,B as b,bn as de,b2 as k,b3 as V,b4 as _,b5 as K,L as n,N as j,b7 as R,bO as oe}from"./index-DGo-vssZ.js";import{r as f}from"./vendor-Qgthw7N1.js";import{i as L}from"./authUtils-CcDzk6i0.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 ce=X("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);function je(){const{user:t,isAuthenticated:Q}=Z(),{toast:l}=ee(),C=se(),[i,Y]=f.useState(null),[$,I]=f.useState(!1),[G,O]=f.useState(!1);f.useEffect(()=>{(!t||t.role!=="super_admin"&&t.role!=="org_admin")&&(window.location.href="/")},[t]),f.useEffect(()=>{t!=null&&t.organizationId&&!i&&Y(t.organizationId)},[t,i]);const{data:s,isLoading:me}=v({queryKey:["/api/organizations",i],enabled:!!i,retry:!1}),{data:w,isLoading:J}=v({queryKey:["/api/organizations",i,"users"],enabled:!!i,retry:!1}),{data:d,isLoading:W}=v({queryKey:["/api/organizations",i,"invitations"],enabled:!!i,retry:!1}),{data:o,isLoading:H}=v({queryKey:["/api/organizations",i,"billing"],enabled:!!i,retry:!1}),D=U({mutationFn:async a=>await T("POST",`/api/organizations/${i}/invitations`,a),onSuccess:()=>{l({title:"Invitation Sent",description:"User invitation has been sent successfully."}),C.invalidateQueries({queryKey:["/api/organizations",i,"invitations"]}),I(!1)},onError:a=>{if(L(a)){l({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{window.location.href="/api/login"},500);return}l({title:"Error",description:"Failed to send invitation.",variant:"destructive"})}}),P=U({mutationFn:async({userId:a,role:r})=>await T("PUT",`/api/users/${a}/role`,{role:r}),onSuccess:()=>{l({title:"Role Updated",description:"User role has been updated successfully."}),C.invalidateQueries({queryKey:["/api/organizations",i,"users"]})},onError:a=>{if(L(a)){l({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{window.location.href="/api/login"},500);return}l({title:"Error",description:"Failed to update user role.",variant:"destructive"})}}),S=U({mutationFn:async a=>await T("PUT",`/api/organizations/${i}/branding`,a),onSuccess:()=>{l({title:"Branding Updated",description:"Organization branding has been updated successfully."}),C.invalidateQueries({queryKey:["/api/organizations",i]}),O(!1)},onError:a=>{if(L(a)){l({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{window.location.href="/api/login"},500);return}l({title:"Error",description:"Failed to update branding.",variant:"destructive"})}});return!Q||!t?e.jsx("div",{children:"Loading..."}
6):i?e.jsxs("div",{className:"container mx-auto py-8 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Organization Admin"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your organization settings, users, and billing"})]}),t.role==="super_admin"&&e.jsxs(g,{variant:"outline",className:"bg-gradient-to-r from-yellow-400 to-orange-500 text-white",children:[e.jsx(ae,{className:"h-3 w-3 mr-1"}),"Super Admin"]})]}),s&&e.jsxs(c,{children:[e.jsxs(m,{children:[e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5"}),s.name]}),e.jsxs(u,{children:["Organization ID: ",s.orgId," • Status: ",s.status]})]}),e.jsx(h,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:s.userCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-green-600",children:s.activeUsers}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Active Users"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:s.subscriptionTier}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Subscription"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:new Date(s.createdAt).toLocaleDateString()}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Created"})]})]})})]}),e.jsxs(ie,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(re,{className:"grid w-full grid-cols-4",children:[e.jsxs(y,{value:"users",className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4"}),"Users"]}),e.jsxs(y,{value:"invitations",className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"Invitations"]}),e.jsxs(y,{value:"branding",className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-4 w-4"}),"Branding"]}),e.jsxs(y,{value:"billing",className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),"Billing"]})]}),e.jsx(N,{value:"users",children:e.jsxs(c,{children:[e.jsxs(m,{children:[e.jsx(x,{children:"Organization Users"}),e.jsx(u,{children:"Manage user roles and permissions"})]}),e.jsx(h,{children:J?e.jsx("div",{children:"Loading users..."}):e.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-medium",children:[a.firstName," ",a.lastName]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:a.email}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(g,{variant:a.status==="active"?"default":"secondary",children:a.status}),e.jsx(g,{variant:"outline",children:a.role})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(E,{value:a.role,onValueChange:r=>P.mutate({userId:a.id,role:r}),disabled:P.isPending,children:[e.jsx(B,{className:"w-32",children:e.jsx(A,{})}),e.jsxs(M,{children:[e.jsx(p,{value:"team_member",children:"Team Member"}),e.jsx(p,{value:"org_admin",children:"Org Admin"}),a.role==="super_admin"&&e.jsx(p,{value:"super_admin",children:"Super Admin"})]})]})})]},a.id))})})]})}),e.jsx(N,{value:"invitations",children:e.jsxs(c,{children:[e.jsxs(m,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(x,{children:"User Invitations"}),e.jsx(u,{children:"Send invitations to new team members"})]}),e.jsxs(q,{open:$,onOpenChange:I,children:[e.jsx(z,{asChild:!0,children:e.jsxs(b,{children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),"Send Invitation"]})}),e.jsxs(k,{children:[e.jsxs(V,{children:[e.jsx(_,{children:"Send User Invitation"}),e.jsx(K,{children:"Invite a new user to join your organization"})]}),e.jsxs("form",{onSubmit:a=>{a.preventDefault();const r=new FormData(a.currentTarget);D.mutate({email:r.get("email"),role:r.get("role")})},children:[e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"email",children:"Email Address"}),e.jsx(j,{id:"email",name:"email",type:"email",placeholder:"[email protected]",required:!0})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"role",children:"Role"}),e.jsxs(E,{name:"role",defaultValue:"team_member",children:[e.jsx(B,{children:e.jsx(A,{})}),e.jsxs(M,{children:[e.jsx(p,{value:"team_member",children:"Team Member"}),e.jsx(p,{value:"org_admin",children:"Organization Admin"})]})]})]})]}),e.jsx(R,{children:e.jsx(b,{type:"submit",disabled:D.isPending,children:D.isPending?"Sending...":"Send Invitation"})})]})]})]})]}),e.jsx(h,{children:W?e.jsx("div",{children:"Loading invitations..."}):e.jsxs("div",{className:"space-y-4",children:[d==null?void 0:d.map(a=>e.jsx("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:a.email}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(g,{variant:a.status==="pending"?"secondary":"default",children:a.status}),e.jsx(g,{variant:"outline",children:a.role})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Expires: ",new Date(a.expiresAt).toLocaleDateString()]})]})},a.id)),!(d!=null&&d.length)&&e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No pending invitations"})]})})]})}),e.jsx(N,{value:"branding",children:e.jsxs(c,{children:[e.jsxs(m,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(x,{children:"White-Label Branding"}),e.jsx(u,{children:"Customize your organization's appearance"})]}),e.jsxs(q,{open:G,onOpenChange:O,children:[e.jsx(z,{asChild:!0,children:e.jsxs(b,{children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}
6),"Update Branding"]})}),e.jsxs(k,{className:"max-w-md",children:[e.jsxs(V,{children:[e.jsx(_,{children:"Update Branding"}),e.jsx(K,{children:"Customize your organization's appearance"})]}),e.jsxs("form",{onSubmit:a=>{a.preventDefault();const r=new FormData(a.currentTarget);S.mutate({logoUrl:r.get("logoUrl"),primaryColor:r.get("primaryColor"),secondaryColor:r.get("secondaryColor"),platformTitle:r.get("platformTitle"),customDomain:r.get("customDomain")})},children:[e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"platformTitle",children:"Platform Title"}),e.jsx(j,{id:"platformTitle",name:"platformTitle",placeholder:"Your Platform Name",defaultValue:(s==null?void 0:s.platformTitle)||""})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"logoUrl",children:"Logo URL"}),e.jsx(j,{id:"logoUrl",name:"logoUrl",placeholder:"https://example.com/logo.png",defaultValue:(s==null?void 0:s.logoUrl)||""})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"primaryColor",children:"Primary Color"}),e.jsx(j,{id:"primaryColor",name:"primaryColor",type:"color",defaultValue:(s==null?void 0:s.primaryColor)||"#3b82f6"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"secondaryColor",children:"Secondary Color"}),e.jsx(j,{id:"secondaryColor",name:"secondaryColor",type:"color",defaultValue:(s==null?void 0:s.secondaryColor)||"#6b7280"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"customDomain",children:"Custom Domain"}),e.jsx(j,{id:"customDomain",name:"customDomain",placeholder:"app.yourdomain.com",defaultValue:(s==null?void 0:s.customDomain)||""})]})]}),e.jsx(R,{children:e.jsx(b,{type:"submit",disabled:S.isPending,children:S.isPending?"Updating...":"Update Branding"})})]})]})]})]}),e.jsx(h,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Platform Title"}),e.jsx("div",{className:"text-lg font-medium",children:(s==null?void 0:s.platformTitle)||"REPSShield"})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Custom Domain"}),e.jsx("div",{className:"text-lg font-medium",children:(s==null?void 0:s.customDomain)||"Not configured"})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded border",style:{backgroundColor:(s==null?void 0:s.primaryColor)||"#3b82f6"}}),e.jsx("span",{children:(s==null?void 0:s.primaryColor)||"#3b82f6"})]})]}),e.jsxs("div",{children:[e.jsx(n,{children:"Secondary Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded border",style:{backgroundColor:(s==null?void 0:s.secondaryColor)||"#6b7280"}}),e.jsx("span",{children:(s==null?void 0:s.secondaryColor)||"#6b7280"})]})]})]}),(s==null?void 0:s.logoUrl)&&e.jsxs("div",{children:[e.jsx(n,{children:"Logo"}),e.jsx("img",{src:s.logoUrl,alt:"Organization Logo",className:"h-16 w-auto border rounded"})]})]})})]})}),e.jsx(N,{value:"billing",children:e.jsxs(c,{children:[e.jsxs(m,{children:[e.jsx(x,{children:"Billing History"}),e.jsx(u,{children:"View organization billing events and transactions"})]}),e.jsx(h,{children:H?e.jsx("div",{children:"Loading billing history..."}):e.jsxs("div",{className:"space-y-4",children:[o==null?void 0:o.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:a.eventType}),e.jsx("div",{className:"text-sm text-muted-foreground",children:a.description}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:new Date(a.createdAt).toLocaleDateString()})]}),e.jsx("div",{className:"text-right",children:e.jsxs("div",{className:"font-medium",children:[a.amount>0?"+":"",a.amount," ",a.currency.toUpperCase()]})})]},a.id)),!(o!=null&&o.length)&&e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No billing events found"})]})})]})})]})]}):e.jsx("div",{className:"container mx-auto py-8",children:e.jsxs(c,{children:[e.jsxs(m,{children:[e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5"}),"Organization Management"]}),e.jsx(u,{children:"Select an organization to manage"})]}),e.jsx(h,{children:e.jsx("p",{className:"text-muted-foreground",children:"No organization selected. Contact your system administrator."})})]})})}export{je 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.