"use strict";(self.webpackChunkportal_ui=self.webpackChunkportal_ui||[]).push([[9221],{49221:function(e,s,t){t.r(s);var r=t(29439),n=t(72791),l=t(29945),o=t(40986),i=t(23814),a=t(81207),d=t(83658),u=t(56028),c=t(87995),h=t(81551),x=t(80184);s.default=function(e){var s=e.open,t=e.checkedUsers,p=e.closeModalAndRefresh,j=(0,h.TL)(),f=(0,n.useState)(!1),b=(0,r.Z)(f,2),g=b[0],m=b[1],k=(0,n.useState)(!1),S=(0,r.Z)(k,2),Z=S[0],v=S[1],w=(0,n.useState)([]),C=(0,r.Z)(w,2),U=C[0],z=C[1];(0,n.useEffect)((function(){g&&(U.length>0?a.Z.invoke("PUT","/api/v1/users-groups-bulk",{groups:U,users:t}).then((function(){m(!1),v(!0)})).catch((function(e){m(!1),j((0,c.zb)(e))})):(m(!1),j((0,c.zb)({errorMessage:"You need to select at least one group to assign",detailedError:""}))))}),[g,m,p,U,t,j]);return(0,x.jsx)(u.Z,{modalOpen:s,onClose:function(){p(Z)},title:Z?"The selected users were added to the following groups.":"Add Users to Group",titleIcon:(0,x.jsx)(l.ZmA,{}),children:Z?(0,x.jsx)(n.Fragment,{children:(0,x.jsxs)(l.ltY,{withBorders:!1,containerPadding:!1,sx:{margin:"30px 0"},children:[(0,x.jsx)(l.bSr,{label:"Groups",sx:{width:"100%"},children:U.join(", ")}),(0,x.jsxs)(l.bSr,{label:"Users",sx:{width:"100%"},children:[" ",t.join(", ")," "]})]})}):(0,x.jsxs)("form",{noValidate:!0,autoComplete:"off",onSubmit:function(e){e.preventDefault(),m(!0)},children:[(0,x.jsxs)(l.ltY,{withBorders:!1,containerPadding:!1,children:[(0,x.jsx)(l.bSr,{label:"Selected Users",sx:{width:"100%"},children:t.join(", ")}),(0,x.jsx)(d.Z,{selectedGroups:U,setSelectedGroups:z})]}),(0,x.jsxs)(l.rjZ,{item:!0,xs:12,sx:i.ID.modalButtonBar,children:[(0,x.jsx)(l.zxk,{id:"clear-bulk-add-group",type:"button",variant:"regular",color:"primary",onClick:function(){z([])},label:"Clear"}),(0,x.jsx)(l.zxk,{id:"save-add-group",type:"submit",variant:"callAction",disabled:g||U.length<1,label:"Save"})]}),g&&(0,x.jsx)(l.rjZ,{item:!0,xs:12,children:(0,x.jsx)(o.Z,{})})]})})}}}]);
//# sourceMappingURL=9221.ef026a1e.chunk.js.map