const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UserForm-7kWuQ5qN.js","assets/render-D1ZqzUbP.js","assets/utils-VIUIl18e.js","assets/TextField-B6uk33js.js","assets/Select-Ht3nAO4Q.js","assets/formControlState-C1XOL3mQ.js","assets/isMuiElement-BcEQvMml.js","assets/Base-Qt2-pbvB.js","assets/Button-DJ_uYab0.js","assets/Link-4dUp4u44.js","assets/Grid-BihMtcd8.js","assets/DeleteUserDialog-DIJDLuCk.js","assets/DialogTitle-J__fqFcw.js","assets/Dialog-aanaDG86.js","assets/Alert-M7jUzTjE.js","assets/DialogContentText-BSyscD7T.js","assets/DialogActions-JiHQNj-t.js"])))=>i.map(i=>d[i]);
import{r as o,a as D,j as e,u as y,B as i,I as f,T as B}from"./render-D1ZqzUbP.js";import{_ as z,L as d}from"./LinearProgress-a_GyCmbh.js";import{B as O,T as R,a as U,b as v,c as g,d as a,e as w}from"./Base-Qt2-pbvB.js";import{D as I}from"./Delete-BKYo-wX-.js";import{E as $}from"./Edit-Dg4av1tV.js";import{g as u}from"./utils-VIUIl18e.js";import{G as L}from"./Grid-BihMtcd8.js";import{B as G}from"./Button-DJ_uYab0.js";import{D as P}from"./Dialog-aanaDG86.js";import"./formControlState-C1XOL3mQ.js";import"./Select-Ht3nAO4Q.js";import"./Link-4dUp4u44.js";import"./isMuiElement-BcEQvMml.js";const b=o.lazy(()=>z(()=>import("./UserForm-7kWuQ5qN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),A=o.lazy(()=>z(()=>import("./DeleteUserDialog-DIJDLuCk.js"),__vite__mapDeps([11,1,2,7,5,4,8,9,10,6,12,13,14,15,16])));function F(){const[h,C]=o.useState(null),[x,_]=o.useState([]),[T,r]=o.useState(!1),[E,c]=o.useState(null),{localeMessages:n,direction:p,userRole:j,apiBaseUrl:m,platformBaseUrl:k,organizationId:t}=y(),l=()=>{fetch(`${m}/organizations/${t}/users/`,{method:"GET",headers:{"Content-Type":"application/json","X-CSRFToken":u("csrftoken")}}).then(s=>s.json()).then(s=>{_(s.organization_users)}).catch(s=>{console.error("Error fetching organization users:",s)})};o.useEffect(()=>{fetch(`${m}/organizations/${t}/`,{method:"GET",headers:{"Content-Type":"application/json","X-CSRFToken":u("csrftoken")}}).then(s=>s.json()).then(s=>{C(s)}).catch(s=>{console.error("Error fetching organization:",s)}),l()},[]);const S=s=>{c(e.jsx(o.Suspense,{fallback:e.jsx(i,{sx:{p:2},children:e.jsx(d,{})}),children:e.jsx(b,{organizationId:t,onClose:()=>r(!1),refreshUsers:l,user:s})})),r(!0)};return e.jsxs(O,{breadCrumbList:[{label:n.organizations,href:`${k}/organizations`,index:0},{label:h?h.name:"",href:"#",index:1}],showOrganizationSwitcher:!1,children:[e.jsx(L,{size:12,py:2,px:4,children:e.jsxs(i,{sx:{p:2,border:"1px solid",borderColor:"border.main",backgroundColor:"background.box",borderRadius:2,minHeight:300},children:[e.jsx(G,{variant:"contained",color:"secondary",onClick:()=>{c(e.jsx(o.Suspense,{fallback:e.jsx(i,{sx:{p:2},children:e.jsx(d,{})}),children:e.jsx(b,{organizationId:t,onClose:()=>r(!1),refreshUsers:l})})),r(!0)},children:n.add_user}),e.jsx(i,{sx:{mt:2,width:"100%"},children:x.length>0?e.jsx(R,{children:e.jsxs(U,{children:[e.jsx(v,{children:e.jsxs(g,{children:[e.jsx(a,{children:n.user}),e.jsx(a,{children:n.role}),j!=="viewer"&&e.jsx(a,{align:p==="rtl"?"left":"right",children:n.actions})]})}),e.jsx(w,{children:x.map(s=>e.jsxs(g,{children:[e.jsx(a,{children:s.email}),e.jsx(a,{children:s.role}),j!=="viewer"&&e.jsxs(a,{align:p==="rtl"?"left":"right",children:[e.jsx(f,{onClick:()=>{S(s)},children:e.jsx($,{fontSize:"small"})}),e.jsx(f,{"aria-label":`Delete ${s.email}`,onClick:()=>{c(e.jsx(o.Suspense,{fallback:e.jsx(i,{sx:{p:2},children:e.jsx(d,{})}),children:e.jsx(A,{user:s,handleClose:()=>r(!1),handleSuccess:()=>{l(),r(!1)}})})),r(!0)},children:e.jsx(I,{fontSize:"small"})})]})]},s.user_id))})]})}):e.jsx(B,{variant:"body1",children:n.no_users_in_organization})})]})}),e.jsx(P,{open:T,onClose:()=>r(!1),fullWidth:!0,maxWidth:"sm",children:E})]})}D({children:e.jsx(F,{})});
//# sourceMappingURL=platform_organization-x2xE8e6i.js.map
