const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OrganizationForm-AjwCh7xh.js","assets/render-BEL5IN7j.js","assets/RequiredTextField-egwBrnFU.js","assets/TextField-9E0h2GEt.js","assets/Select-DyY0x5OK.js","assets/formControlState-YO0xWqIm.js","assets/isMuiElement-e1vpiHuY.js","assets/ImageUpload-D-S9cmVu.js","assets/utils-MPtJ5ynp.js","assets/Button-CGPZXh3G.js","assets/Alert-DGyy5JNc.js","assets/DialogActions-CUWg4ydV.js"])))=>i.map(i=>d[i]);
import{d as I,j as e,r as n,o as D,n as L,B as a,P as A,I as d,T as w}from"./render-BEL5IN7j.js";import{_ as P,L as j}from"./LinearProgress-CxAdYH_V.js";import{B as R,T as F,a as U,b as M,c as u,d as l,e as N}from"./Base-B0IvxOwn.js";import{P as $}from"./Add-D-mBBsbs.js";import{D as G}from"./Delete-B4sDn-7L.js";import{E as H}from"./Edit-Bdr29V7f.js";import{g as b}from"./utils-MPtJ5ynp.js";import{G as V}from"./Grid-CY2FZLhF.js";import{B as m}from"./Button-CGPZXh3G.js";import{L as W}from"./Link-u7JOT8iP.js";import{D as X}from"./Dialog-CGu6k_Gi.js";import{A as Z}from"./Alert-DGyy5JNc.js";import"./formControlState-YO0xWqIm.js";import"./Select-DyY0x5OK.js";import"./SwitchBase-DFAnYP3H.js";import"./isMuiElement-e1vpiHuY.js";const q=I(e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39"})),C=n.lazy(()=>P(()=>import("./OrganizationForm-AjwCh7xh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])));function J(){const{localeMessages:r,direction:z,apiBaseUrl:x,platformBaseUrl:k}=L(),[T,o]=n.useState(!1),[y,c]=n.useState(null),[h,E]=n.useState([]),[S,p]=n.useState([]);n.useEffect(()=>{fetch(`${x}/organizations/`,{method:"GET",headers:{"Content-Type":"application/json","X-CSRFToken":b("csrftoken")}}).then(s=>s.json()).then(s=>{E(s.organizations)}).catch(s=>{console.error("Error fetching organizations:",s)})},[S]);const f=s=>{console.log("Organization created successfully:",s),o(!1),p(i=>[...i,s])},g=s=>{console.error("Error creating organization:",s)},_=s=>{window.open(s,"_blank")},O=s=>{fetch(`${x}/organizations/${s}/`,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRFToken":b("csrftoken")}}).then(i=>{i.ok?(console.log("Organization deleted successfully"),p(B=>[...B,{deletedOrganizationId:s}])):console.error("Error deleting organization")}).catch(i=>{console.error("Error deleting organization:",i)})},t=document.getElementsByTagName("html")[0],v=s=>{c(e.jsxs(a,{sx:{p:2},children:[e.jsx(w,{variant:"h6",children:r.confirm_deletion}),e.jsx(Z,{severity:"warning",variant:"outlined",sx:{mt:1},children:r.are_you_sure_delete_org.replace("ORGANIZATION_NAME",s.name)}),e.jsxs(a,{sx:{display:"flex",justifyContent:"flex-end",mt:2},children:[e.jsx(m,{onClick:()=>o(!1),sx:{mr:1},children:r.cancel}),e.jsx(m,{variant:"contained",color:"error",onClick:()=>{O(s.id),o(!1)},children:r.delete})]})]})),o(!0)};return e.jsxs(R,{breadCrumbList:[{label:r.organizations,href:"#"}],showOrganizationSwitcher:!1,children:[e.jsx(V,{size:12,py:2,pl:2,children:e.jsxs(a,{p:2,sx:{border:"1px solid",borderColor:"grey.300",borderRadius:1,minHeight:300,width:{lg:"80%"}},children:[e.jsx(m,{variant:"contained",startIcon:e.jsx($,{sx:{marginLeft:z=="rtl"?1:0}}),sx:{marginBottom:2},onClick:()=>{c(e.jsx(n.Suspense,{fallback:e.jsx(a,{sx:{p:2},children:e.jsx(j,{})}),children:e.jsx(C,{successCallback:f,failureCallback:g,cancelCallback:()=>o(!1),createMode:!0})})),o(!0)},children:r.add_organization}),h.length>0&&e.jsx(F,{component:A,sx:{maxHeight:440,border:"1px solid",borderColor:"grey.300",borderRadius:1},children:e.jsxs(U,{children:[e.jsx(M,{children:e.jsxs(u,{children:[e.jsx(l,{dir:t.dir,sx:{textAlign:t.dir==="rtl"?"right":"left"},children:r.name}),e.jsx(l,{sx:{width:"100px"},children:r.actions})]})}),e.jsx(N,{children:h.map(s=>e.jsxs(u,{children:[e.jsx(l,{dir:t.dir,sx:{textAlign:t.dir==="rtl"?"right":"left"},children:e.jsx(W,{color:"primary.dark",href:`${k}/organizations/${s.id}/`,children:s.name})}),e.jsxs(l,{children:[e.jsx(d,{onClick:()=>_(s.public_url),children:e.jsx(q,{fontSize:"small"})}),e.jsx(d,{onClick:()=>{c(e.jsx(n.Suspense,{fallback:e.jsx(a,{sx:{p:2},children:e.jsx(j,{})}),children:e.jsx(C,{successCallback:f,failureCallback:g,cancelCallback:()=>o(!1),createMode:!1,initialName:s.name,initialDescription:s.description,initialLogoUrl:s.logo,organizationId:s.id})})),o(!0)},children:e.jsx(H,{fontSize:"small"})}),e.jsx(d,{onClick:()=>v(s),children:e.jsx(G,{fontSize:"small"})})]})]},s.id))})]})})]})}),e.jsx(X,{open:T,onClose:()=>o(!1),fullWidth:!0,maxWidth:"sm",children:y})]})}D({children:e.jsx(J,{})});
//# sourceMappingURL=organizations--19f1lSm.js.map
