import{aI as f,L as p,ao as e,aq as o,aC as y,bU as U,cb as r,ax as P,V as b,az as w,aj as k,b0 as v,iw as M,bc as T,iP as R,aF as D,dZ as N,p as A,W as I,E as L,r as B,o as C,co as E,O as j}from"./app-k0jcl5PQ.js";import{U as F}from"./B4GO8DD1.chunk.js";import{U as V}from"./9ls1F1Ve.chunk.js";import"./fstW5ZQE.chunk.js";const n="userManager.deleteUser",O={[r.Learner]:"userManager.deleteStudent",[r.Staff]:"userManager.deleteStaff",[r.Unknown]:"",[r.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,i]=f.useState(""),[l,u]=f.useState(!1),[x,m]=f.useState(!1),d=O[s.userType];f.useEffect(()=>{if(t){if(t.toLowerCase().trim()===p.getPhrase(n,"deletePhrase")){u(!0);return}l&&u(!1)}},[t]);function h(){m(!0),s.onClickDelete()}return e.jsxs(e.Fragment,{children:[(()=>{var g;if(!((g=s.users)!=null&&g.length)||s.totalUsers>1)return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:e.jsx(o,{namespace:d,phrase:"infoManyUsers",options:{total:s.totalUsers}})}),e.jsx(S,{})]});const a=y.first(s.users),c=`${a.name}${a.surname?` ${a.surname}`:""}`;return e.jsxs(e.Fragment,{children:[e.jsx("p",{children:e.jsx(o,{namespace:d,phrase:"infoOneUser",options:{name:c.trim()?c:a.username}})}),e.jsx(S,{}),a.name&&e.jsx(q,{name:c,username:a.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:a=>i(a.target.value),autoComplete:"off",className:`form-control w-75 ${s.inputSize==="lg"?"form-control-lg":""}`})]}),e.jsxs(U,{children:[e.jsx(U.Cancel,{onClick:s.onClickCancel}),e.jsx(U.Submit,{variant:"danger",onClick:h,text:p.getPhrase(n,"delete",{smartCount:s.totalUsers}),showSpinner:x,disabled:!l})]})]})}const H={[r.Learner]:"userManager.bulkRemoveStudents",[r.Staff]:"userManager.bulkRemoveStaff",[r.Unknown]:"",[r.System]:""};function _(s){const[t]=P(b.BULK_REMOVE_USERS),i=p.encloseNamespace(H[s.userType]),l=w(k.currentUser()),u=v(),x=M(),m=T();function d(){const h=t.allUsers?[]:t.users,a=N.formatDeleteRequest(l.data.customerId,h,s.userType);u(V.bulkRemoveUsers(a,()=>{const c={actionType:B.Delete,entity:L.User,workflowPhase:I.Complete,location:A.Popup};t.allUsers?C.logUserAction({count:"all",query:E.omit(a,["customerId"])},{...c,descriptor:j.All}):C.logUserAction({count:t.totalUsers},{...c,descriptor:t.totalUsers===1?j.Single:j.Bulk}),setTimeout(()=>{x(["user:count"])},2e3),m.success(i("success",{smartCount:t.totalUsers,escapeText:!0}))},()=>{m.error(i("error"))},()=>{s.closePopup()}))}return e.jsx(F.Provider,{value:R.Primary,children:e.jsx(D,{title:i("title",{smartCount:t.totalUsers}),closePopup:s.closePopup,showLoadingSpinner:!l.data,children:!!l.data&&e.jsx($,{users:t.users,totalUsers:t.totalUsers,userType:s.userType,onClickCancel:s.closePopup,onClickDelete:d})})})}export{_ as BulkRemoveUsersView};
//# sourceMappingURL=Daio4zXN.chunk.js.map
