const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UserForm-CUW3S7pI.js","assets/render-BEL5IN7j.js","assets/utils-MPtJ5ynp.js","assets/TextField-9E0h2GEt.js","assets/Select-DyY0x5OK.js","assets/formControlState-YO0xWqIm.js","assets/isMuiElement-e1vpiHuY.js","assets/Base-B0IvxOwn.js","assets/SwitchBase-DFAnYP3H.js","assets/Link-u7JOT8iP.js","assets/Grid-CY2FZLhF.js","assets/Button-CGPZXh3G.js","assets/DeleteUserDialog-46tpMdeO.js","assets/DialogTitle-D3yk6KnK.js","assets/Dialog-CGu6k_Gi.js","assets/Alert-DGyy5JNc.js","assets/DialogActions-CUWg4ydV.js"])))=>i.map(i=>d[i]);
import{r,o as y,j as e,n as D,B as l,I as f,T as B}from"./render-BEL5IN7j.js";import{_ as z,L as d}from"./LinearProgress-CxAdYH_V.js";import{B as R,T as O,a as U,b as v,c as g,d as a,e as w}from"./Base-B0IvxOwn.js";import{D as I}from"./Delete-B4sDn-7L.js";import{E as $}from"./Edit-Bdr29V7f.js";import{g as u}from"./utils-MPtJ5ynp.js";import{G as L}from"./Grid-CY2FZLhF.js";import{B as G}from"./Button-CGPZXh3G.js";import{D as P}from"./Dialog-CGu6k_Gi.js";import"./formControlState-YO0xWqIm.js";import"./Select-DyY0x5OK.js";import"./SwitchBase-DFAnYP3H.js";import"./Link-u7JOT8iP.js";import"./isMuiElement-e1vpiHuY.js";const b=r.lazy(()=>z(()=>import("./UserForm-CUW3S7pI.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),A=r.lazy(()=>z(()=>import("./DeleteUserDialog-46tpMdeO.js"),__vite__mapDeps([12,1,2,7,5,4,8,9,10,6,13,14,15,16,11])));function F(){const[h,C]=r.useState(null),[x,_]=r.useState([]),[T,o]=r.useState(!1),[E,c]=r.useState(null),{localeMessages:n,direction:p,userRole:m,apiBaseUrl:j,platformBaseUrl:S,organizationId:i}=D(),t=()=>{fetch(`${j}/organizations/${i}/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)})};r.useEffect(()=>{fetch(`${j}/organizations/${i}/`,{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)}),t()},[]);const k=s=>{c(e.jsx(r.Suspense,{fallback:e.jsx(l,{sx:{p:2},children:e.jsx(d,{})}),children:e.jsx(b,{organizationId:i,onClose:()=>o(!1),refreshUsers:t,user:s})})),o(!0)};return e.jsxs(R,{breadCrumbList:[{label:n.organizations,href:`${S}/organizations`,index:0},{label:h?h.name:"",href:"#",index:1}],showOrganizationSwitcher:!1,children:[e.jsxs(L,{size:12,py:2,px:4,container:!0,sx:{borderColor:"grey.300",borderRadius:1,borderWidth:1,borderStyle:"solid",mt:2},children:[e.jsx(G,{variant:"contained",color:"primary",onClick:()=>{c(e.jsx(r.Suspense,{fallback:e.jsx(l,{sx:{p:2},children:e.jsx(d,{})}),children:e.jsx(b,{organizationId:i,onClose:()=>o(!1),refreshUsers:t})})),o(!0)},children:n.add_user}),e.jsx(l,{sx:{p:2,mt:2,borderRadius:1,bgcolor:"background.paper",width:"100%"},children:x.length>0?e.jsx(O,{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}),m!=="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}),m!=="viewer"&&e.jsxs(a,{align:p==="rtl"?"left":"right",children:[e.jsx(f,{onClick:()=>{k(s)},children:e.jsx($,{fontSize:"small"})}),e.jsx(f,{"aria-label":`Delete ${s.email}`,onClick:()=>{c(e.jsx(r.Suspense,{fallback:e.jsx(l,{sx:{p:2},children:e.jsx(d,{})}),children:e.jsx(A,{user:s,handleClose:()=>o(!1),handleSuccess:()=>{t(),o(!1)}})})),o(!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:()=>o(!1),fullWidth:!0,maxWidth:"sm",children:E})]})}y({children:e.jsx(F,{})});
//# sourceMappingURL=platform_organization-DaGGszdr.js.map
