import{R as k,ck as a,j as t,b7 as C,a9 as m,F as U,o as d,es as S,k as A,l as M,E as w,aR as P}from"./app-BgLa5dit.js";import{U as T}from"./ZKp_vc-v.chunk.js";import{a as R}from"./m4aqaK_l.chunk.js";import{C as x,U as b}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 g="userManager.toggleUserStatus",E=U.encloseNamespace(g);function $(e){const[c,o]=k.useState(!1),s=e.user;function u(){o(!0),e.onClickConfirm()}const l=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(C,{namespace:g,phrase:e.newStatus===a.Active?"activateCheck":"deactivateCheck",options:{name:`${s.name}${s.surname?` ${s.surname}`:""} (${s.username})`}})}),t.jsx("ul",{children:l.map(r=>t.jsx("li",{children:t.jsx(C,{namespace:g,phrase:r})},r))}),t.jsxs(m,{children:[t.jsx(m.Cancel,{onClick:e.onClickCancel}),t.jsx(m.Submit,{variant:e.newStatus===a.Disabled?"danger":"dark",onClick:u,text:E(e.newStatus===a.Disabled?"deactivate":"activate"),showSpinner:c})]})]})}const q="userManager.toggleUserStatusView",i=U.encloseNamespace(q),F=e=>e?e.status!==a.Active?i("reactivateTitle"):i("deactivateTitle"):"";function W(e){var h;const c=d(x.getUser(e.customerId,e.id)),o=d(c.hasError&&S.user(e.id)),s=c.hasError?o:c,u=d(P.currentUser()),l=A(),r=M(),n=((h=s.data)==null?void 0:h.status)===a.Active?a.Disabled:a.Active;function f(){const j=b.formatToggleStatusRequest(s.data,e.customerId,n),p=e.customerId?x.bulkToggleActivation(e.customerId,j,e.userType):S.toggleActivation(e.id,n);l(p).then(()=>{r.success(i(n===a.Active?"reactivateSuccess":"deactivateSuccess")),e.closePopup()}).catch(()=>{r.error(i(n===a.Active?"reactivateError":"deactivateError")),e.closePopup()})}const v=!!u.data&&!!s.data;return t.jsx(T.Provider,{value:R.Curator,children:t.jsx(w,{title:F(s.data),closePopup:e.closePopup,showLoadingSpinner:!v,children:v&&t.jsx($,{user:s.data,onClickConfirm:f,onClickCancel:e.closePopup,newStatus:n})})})}export{W as ToggleUserStatusView};
//# sourceMappingURL=mn4FqSJq.chunk.js.map
