import{_t as e,lt as r,n as s,yt as t}from"./render-cqdoDfd9.js";import{t as i}from"./Box-pvlRBLzs.js";import{t as o}from"./Typography-8v555lWC.js";import{t as n}from"./Button-D-nJohaT.js";import{t as a}from"./Alert-BpUkH7Nx.js";import{t as l}from"./DialogActions-IskUXpPi.js";import{n as c,t as d}from"./DialogTitle-HCb6VQhm.js";import{t as m}from"./DialogContentText-EZ4FAf5e.js";import{t as h}from"./Warning-CywfiYbG.js";import{t as j}from"./utils-C0ZHLGh_.js";var p=t(e(),1),x=r(),f=({user:e,handleClose:r,handleSuccess:t})=>{const{localeMessages:f,apiBaseUrl:u}=s(),[g,E]=(0,p.useState)("");return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d,{id:"alert-dialog-title",children:[g&&(0,x.jsx)(a,{severity:"error",children:g}),(0,x.jsxs)(o,{variant:"h6",component:"span",children:[(0,x.jsx)(i,{sx:{display:"inline-block",alignItems:"center",mr:1,mt:1,pt:1},children:(0,x.jsx)(h,{color:"warning"})}),(0,x.jsx)(i,{sx:{display:"inline-block"},children:f.delete_user_with_email.replace("USER_EMAIL",e.email)})]})]}),(0,x.jsxs)(c,{children:[(0,x.jsx)(m,{id:"alert-dialog-description",children:f.user_delete_confirmation.replace("USER_EMAIL",e.email)}),(0,x.jsx)(a,{severity:"info",sx:{mt:2},children:f.delete_note})]}),(0,x.jsxs)(l,{children:[(0,x.jsx)(n,{onClick:r,children:f.cancel}),(0,x.jsx)(n,{onClick:()=>{fetch(`${u}/organizations/${e.organization_id}/users/${e.id}/`,{method:"DELETE",headers:{"Content-Type":"application/json","X-CSRFToken":j("csrftoken")}}).then(e=>{if(200!=e.status)throw new Error("Unhandled network Error! user is not deleted");return e.json()}).then(e=>{if(e.error)throw new Error(e.error);t()}).catch(e=>{E(e.message)})},autoFocus:!0,variant:"contained",children:(0,x.jsx)(o,{children:f.delete})})]})]})};export{f as default};