import{aI as l,L as m,ao as e,aq as o,ah as h,bU as x,az as g,aj as j,iw as U,b0 as P,bc as C,iP as S,aF as w,cb as u,dZ as y,o as R,O as N,p as b,W as k,E as F,r as T}from"./app-k0jcl5PQ.js";import{U as M}from"./B4GO8DD1.chunk.js";import{U as v}from"./9ls1F1Ve.chunk.js";import"./fstW5ZQE.chunk.js";const r="userManager.removeUser";function A(s){const[a,t]=l.useState(""),[n,c]=l.useState(!1),[d,i]=l.useState(!1);l.useEffect(()=>{if(a){if(a.toLowerCase().trim()===m.getPhrase(r,"removePhrase")){c(!0);return}n&&c(!1)}},[a]);function p(){i(!0),s.onClickRemove()}return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:e.jsx(o,{namespace:r,phrase:"question",options:{name:h.getFullName(s.user)}})}),e.jsx("p",{children:e.jsx(o,{namespace:r,phrase:"info"})}),e.jsx("p",{className:"mb-0 font-weight-500",children:e.jsx(o,{namespace:r,phrase:"name"})}),e.jsx("p",{children:h.getFullName(s.user)}),e.jsx("p",{className:"mb-0 font-weight-500",children:e.jsx(o,{namespace:r,phrase:"username"})}),e.jsx("p",{children:s.user.username}),e.jsxs("div",{className:"form-group",children:[e.jsx("p",{className:"mb-1",children:e.jsx(o,{namespace:r,phrase:"typeRemove",options:{removePhrase:m.getPhrase(r,"removePhrase")}})}),e.jsx("input",{value:a,onChange:f=>t(f.target.value),autoComplete:"off",className:"form-control w-75"})]}),e.jsxs(x,{children:[e.jsx(x.Cancel,{onClick:s.onClickCancel}),e.jsx(x.Submit,{variant:"danger",onClick:p,text:m.getPhrase(r,"remove"),showSpinner:d,disabled:!n})]})]})}const L={[u.Learner]:"userManager.removeStudents",[u.Staff]:"userManager.removeStaff",[u.Unknown]:"",[u.System]:""};function G(s){const a=m.encloseNamespace(L[s.userType]),t=g(v.getUser(s.id)),n=g(j.currentUser()),c=U(),d=P(),i=C();function p(){const f=y.formatDeleteRequest(n.data.customerId,[t.data],s.userType);d(v.removeUsersFromSchool(f)).then(()=>{R.logUserAction({id:s.id,name:t.data.name},{actionType:T.Remove,entity:F.User,workflowPhase:k.Complete,location:b.Popup,descriptor:N.Single}),setTimeout(()=>{c(["user:count"])},2e3),i.success(a("success",{name:h.getFullName(t.data)}))}).catch(()=>{i.error(a("error",{name:h.getFullName(t.data)}))}).finally(s.closePopup)}return e.jsx(M.Provider,{value:S.Primary,children:e.jsx(w,{title:a("title"),closePopup:s.closePopup,showLoadingSpinner:!n.data,children:!!n.data&&!!t.data&&e.jsx(A,{user:t.data,onClickCancel:s.closePopup,onClickRemove:p})})})}export{G as RemoveUserView};
//# sourceMappingURL=B1dAUaqE.chunk.js.map
