import{aI as U,ci as a,ao as t,aq as v,bU as l,L as C,az as p,aj as f,c4 as j,bc as P,iP as A,aF as k,dZ as w,m as M,o as T,p as b,W as y,ch as h,E as $,r as D}from"./app-k0jcl5PQ.js";import{U as E}from"./B4GO8DD1.chunk.js";import{U as S}from"./9ls1F1Ve.chunk.js";import"./fstW5ZQE.chunk.js";const d="userManager.toggleUserStatus",I=C.encloseNamespace(d);function L(e){const[s,r]=U.useState(!1),n=e.user;function i(){r(!0),e.onClickConfirm()}const c=e.newStatus===a.Active?["activateMessage1","activateMessage2","activateMessage3"]:["deactivateMessage1","deactivateMessage2","deactivateMessage3","deactivateMessage4"];return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"p-0",children:t.jsx(v,{namespace:d,phrase:e.newStatus===a.Active?"activateCheck":"deactivateCheck",options:{name:`${n.name}${n.surname?` ${n.surname}`:""} (${n.username})`}})}),t.jsx("ul",{children:c.map(o=>t.jsx("li",{children:t.jsx(v,{namespace:d,phrase:o})},o))}),t.jsxs(l,{children:[t.jsx(l.Cancel,{onClick:e.onClickCancel}),t.jsx(l.Submit,{variant:e.newStatus===a.Disabled?"danger":"dark",onClick:i,text:I(e.newStatus===a.Disabled?"deactivate":"activate"),showSpinner:s})]})]})}const R="userManager.toggleUserStatusView",u=C.encloseNamespace(R),q=e=>e?e.status!==a.Active?u("reactivateTitle"):u("deactivateTitle"):"";function H(e){var m;const s=p(S.getUser(e.id)),r=p(f.currentUser()),n=j(),i=P(),c=((m=s.data)==null?void 0:m.status)===a.Active?a.Disabled:a.Active;function o(){const x=w.formatToggleStatusRequest(s.data,r.data.customerId,c);M(n,S.bulkToggleActivation(x,e.userType,()=>{T.logUserAction({customerId:r.data.customerId,userId:s.data.id},{actionType:D.Activate,entity:$.User,descriptor:c===a.Active?h.On:h.Off,workflowPhase:y.Complete,location:b.Popup}),i.success(u(c===a.Active?"reactivateSuccess":"deactivateSuccess")),e.closePopup()},()=>{i.error(u(c===a.Active?"reactivateError":"deactivateError")),e.closePopup()}))}const g=!!r.data&&!!s.data;return t.jsx(E.Provider,{value:A.Primary,children:t.jsx(k,{title:q(s.data),closePopup:e.closePopup,showLoadingSpinner:!g,children:g&&t.jsx(L,{user:s.data,onClickConfirm:o,onClickCancel:e.closePopup,newStatus:c})})})}export{H as ToggleUserStatusView};
//# sourceMappingURL=Bev2q_jJ.chunk.js.map
