import{j as r,cD as g,R as h,l as C,aP as x,o as d,es as t,dO as j,E as k,aQ as m}from"./app-BgLa5dit.js";function w(e){return r.jsxs("li",{className:"d-flex justify-content-between align-items center my-2",children:[e.group.name,r.jsx(g,{variant:e.userIsInGroup?"danger":"outline-dark",onClick:e.onClickToggleGroup,children:e.userIsInGroup?"Remove user":"Add user"})]})}function p(e,o){return o.map(a=>a.id).includes(e.id)}function y(e){const[o,a]=h.useState(null),u=C(),i=x(),n=d(t.userClickViewGroups(e.id)),c=d(t.clickViewGroups(e.id));function G(){m(i,t.addUserToClickViewGroup(e.id,o.id,()=>u.success(`Successfully added user to ${o.name}`),()=>u.error(`Failed to add user to ${o.name}`),e.closePopup))}function f(){m(i,t.removeUserFromClickViewGroup(e.id,o.id,()=>u.success(`Successfully removed user from ${o.name}`),()=>u.error(`Failed to remove user from ${o.name}`),e.closePopup))}if(o){const s=p(o,n.data);return r.jsx(j,{title:"Manage Curator groups",onClickConfirm:s?f:G,closePopup:e.closePopup,children:r.jsx("p",{children:s?`Are you sure that you want to remove this user from ${o.name}?`:`Are you sure that you want to add this user to ${o.name}?`})})}const l=!!n.data&&!!c.data;return r.jsx(k,{title:"Manage Curator groups",closePopup:e.closePopup,showLoadingSpinner:!l,children:l&&r.jsx("ul",{className:"list-unstyled",children:c.data.map(s=>r.jsx(w,{group:s,userIsInGroup:p(s,n.data),onClickToggleGroup:()=>a(s)},s.id))})})}export{y as ManageUserCuratorGroupsView};
//# sourceMappingURL=Db7LX_JR.chunk.js.map
