import{R as f,F as p,j as e,b7 as o,w as k,a9 as g,bT as a,u as w,o as v,cB as y,k as M,l as P,E as b,V as R,aR as A,es as I,g as N,h as T,i as D}from"./app-BgLa5dit.js";import{U as E}from"./ZKp_vc-v.chunk.js";import{a as B}from"./m4aqaK_l.chunk.js";import{U as F,C as L}from"./q-IBKcuF.chunk.js";import"./DUpYPoLs.chunk.js";import"./EZim8aq-.chunk.js";import"./BD9MrUJP.chunk.js";import"./s6cGcwlA.chunk.js";import"./Zwjmkasg.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";const n="userManager.deleteUser",V={[a.Learner]:"userManager.deleteStudent",[a.Staff]:"userManager.deleteStaff",[a.Unknown]:"",[a.System]:""};function S(){return e.jsxs("ul",{children:[e.jsx("li",{children:e.jsx(o,{namespace:n,phrase:"deleteInfo1"})}),e.jsx("li",{className:"text-danger",children:e.jsx(o,{namespace:n,phrase:"deleteInfo2"})})]})}function q(s){return e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-0 fw-semibold",children:e.jsx(o,{namespace:n,phrase:"name"})}),e.jsx("p",{children:s.name}),e.jsx("p",{className:"mb-0 fw-semibold",children:e.jsx(o,{namespace:n,phrase:"username"})}),e.jsx("p",{children:s.username})]})}function $(s){const[t,l]=f.useState(""),[i,m]=f.useState(!1),[x,d]=f.useState(!1),h=V[s.userType];f.useEffect(()=>{if(t){if(t.toLowerCase().trim()===p.getPhrase(n,"deletePhrase")){m(!0);return}i&&m(!1)}},[t]);function j(){d(!0),s.onClickDelete()}return e.jsxs(e.Fragment,{children:[(()=>{var u;if(!((u=s.users)!=null&&u.length)||s.totalUsers>1)return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:e.jsx(o,{namespace:h,phrase:"infoManyUsers",options:{total:s.totalUsers}})}),e.jsx(S,{})]});const r=k.first(s.users),c=`${r.name}${r.surname?` ${r.surname}`:""}`;return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:e.jsx(o,{namespace:h,phrase:"infoOneUser",options:{name:c.trim()?c:r.username}})}),e.jsx(S,{}),r.name&&e.jsx(q,{name:c,username:r.username})]})})(),e.jsxs("div",{className:"form-group",children:[e.jsx("p",{className:"mb-1",children:e.jsx(o,{namespace:n,phrase:"typeDelete",options:{deletePhrase:p.getPhrase(n,"deletePhrase")}})}),e.jsx("input",{value:t,onChange:r=>l(r.target.value),autoComplete:"off",className:`form-control w-75 ${s.inputSize==="lg"?"form-control-lg":""}`})]}),e.jsxs(g,{children:[e.jsx(g.Cancel,{onClick:s.onClickCancel}),e.jsx(g.Submit,{variant:"danger",onClick:j,text:p.getPhrase(n,"delete",{smartCount:s.totalUsers}),showSpinner:x,disabled:!i})]})]})}const H={[a.Learner]:"userManager.removeStudents",[a.Staff]:"userManager.removeStaff",[a.Unknown]:"",[a.System]:""};function ae(s){const[t]=w(R.BULK_REMOVE_USERS),l=p.encloseNamespace(H[s.userType]),i=v(A.currentUser()),m=y(),x=M(),d=P();function h(){const j=t.allUsers?[]:t.users,r=F.formatDeleteRequest(s.customerId,j,s.userType),c=s.customerId?L.bulkRemoveUsers(s.customerId,r):I.deleteUser(t.users[0].id);x(c).then(()=>{var u,U,C;setTimeout(()=>{m(["user:count"])},2e3),d.success(l("success",{smartCount:t.totalUsers})),N.trigger({application:((u=s.redirectApplink)==null?void 0:u.application)||D.USERS,action:((U=s.redirectApplink)==null?void 0:U.action)||T.Users.HOME,args:((C=s.redirectApplink)==null?void 0:C.args)||[s.customerId]},{replace:!0})}).catch(()=>{d.error(l("error"))}).finally(()=>{s.closePopup()})}return e.jsx(E.Provider,{value:B.Curator,children:e.jsx(b,{title:l("title",{smartCount:t.totalUsers}),closePopup:s.closePopup,showLoadingSpinner:!i.data,children:!!i.data&&e.jsx($,{users:t.users,totalUsers:t.totalUsers,userType:s.userType,onClickCancel:s.closePopup,onClickDelete:h})})})}export{ae as BulkRemoveUsersView};
//# sourceMappingURL=O5Fml9XC.chunk.js.map
