"use strict";(self.webpackChunkweb_app=self.webpackChunkweb_app||[]).push([[6560],{98940:(e,s,t)=>{t.r(s),t.d(s,{default:()=>p});var r=t(69060),l=t(66152),a=t(61628),o=t(50900),n=t(49688),d=t(4836),i=t(95705),c=t(66156),u=t(82496);const p=e=>{let{open:s,checkedUsers:t,closeModalAndRefresh:p}=e;const h=(0,c.Ab)(),[x,j]=(0,r.useState)(!1),[b,g]=(0,r.useState)(!1),[k,f]=(0,r.useState)([]);(0,r.useEffect)((()=>{x&&(k.length>0?o.c.invoke("PUT","/api/v1/users-groups-bulk",{groups:k,users:t}).then((()=>{j(!1),g(!0)})).catch((e=>{j(!1),h((0,i.op)(e))})):(j(!1),h((0,i.op)({errorMessage:"You need to select at least one group to assign",detailedError:""}))))}),[x,j,p,k,t,h]);return(0,u.jsx)(d.c,{modalOpen:s,onClose:()=>{p(b)},title:b?"The selected users were added to the following groups.":"Add Users to Group",titleIcon:(0,u.jsx)(l.aci,{}),children:b?(0,u.jsx)(r.Fragment,{children:(0,u.jsxs)(l.yE_,{withBorders:!1,containerPadding:!1,sx:{margin:"30px 0"},children:[(0,u.jsx)(l.E$k,{label:"Groups",sx:{width:"100%"},children:k.join(", ")}),(0,u.jsxs)(l.E$k,{label:"Users",sx:{width:"100%"},children:[" ",t.join(", ")," "]})]})}):(0,u.jsxs)("form",{noValidate:!0,autoComplete:"off",onSubmit:e=>{e.preventDefault(),j(!0)},children:[(0,u.jsxs)(l.yE_,{withBorders:!1,containerPadding:!1,children:[(0,u.jsx)(l.E$k,{label:"Selected Users",sx:{width:"100%"},children:t.join(", ")}),(0,u.jsx)(n.c,{selectedGroups:k,setSelectedGroups:f})]}),(0,u.jsxs)(l.yeN,{item:!0,xs:12,sx:a.W2.modalButtonBar,children:[(0,u.jsx)(l.qaq,{id:"clear-bulk-add-group",type:"button",variant:"regular",color:"primary",onClick:()=>{f([])},label:"Clear"}),(0,u.jsx)(l.qaq,{id:"save-add-group",type:"submit",variant:"callAction",disabled:x||k.length<1,label:"Save"})]}),x&&(0,u.jsx)(l.yeN,{item:!0,xs:12,children:(0,u.jsx)(l.cHM,{})})]})})}}}]);
//# sourceMappingURL=6560.b4440a7d.chunk.js.map