import{c as G,l as _,bd as B,a as F,sQ as D,h as L,r as x,j as i,I as N,bv as O,M as f,be as j,T as b,sC as r}from"./index-aa586041.js";import{T as R}from"./index-a2d739d4.js";import{T as H}from"./TopComponent-38ced44d.js";import{M as Q}from"./Menu-3823c2ca.js";import{M as v}from"./MenuItem-0cb185cb.js";import"./TableCell-171b9885.js";import"./TableRow-6b2aeb5d.js";import"./index-67899cd7.js";import"./useMediaQuery-64e46ff0.js";import"./TableHead-a20733cc.js";import"./createSvgIcon-26e7576d.js";import"./TablePagination-e8098a58.js";import"./Toolbar-707eb110.js";import"./Select-03e2ed06.js";import"./OutlinedInput-8f0d0162.js";import"./useFormControl-1a7e7d92.js";import"./isHostComponent-73d6e646.js";import"./useControlled-e0c526ba.js";import"./KeyboardArrowRight-881c4d45.js";import"./LastPage-90e6357c.js";import"./yup-75085264.js";import"./index.esm-c1bef48d.js";import"./CustomDatepicker-26155063.js";import"./floating-ui.dom-cd6c919d.js";import"./InputAdornment-2dac8dca.js";import"./index-c5e91153.js";import"./index-1d230708.js";import"./InputLabel-fa135afd.js";import"./index-e3cd0864.js";import"./SectionDivider-2f9208fa.js";import"./resolveProps-185f0451.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-a6efd9c3.js";import"./PageBreadCrumb-654095db.js";import"./PageMetaData-1d7ce7c7.js";import"./Breadcrumbs-64a66b15.js";import"./useSlotProps-01ed14c0.js";import"./Link-03d388f2.js";import"./ScrollableList-fcc6a14c.js";import"./List-d99f3a17.js";import"./index.esm-5d8102a7.js";import"./TextField-5fe8ef1a.js";import"./FormControl-fed32f2b.js";import"./FilterOutlined-c8f43eef.js";import"./AntdIcon-c87bdadf.js";import"./slicedToArray-f5e6f6d2.js";import"./defineProperty-83f36300.js";import"./objectSpread2-e05f2ee3.js";import"./Grow-6aaee206.js";import"./dividerClasses-db0c3f8b.js";import"./listItemTextClasses-6f04b047.js";const Ut=()=>{const n=G(),d=_(),g=B(),{manageGroups:{profileList:C,profileParams:a,loading:z,listCount:P},system:{userAccessList:m}}=F(t=>({manageGroups:D(t),system:L(t)})),S=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Users",width:100},{title:"Actions",width:100}];function M(t,e,s,l){return{index:t,title:e,user:s,actions:l}}const[p,u]=x.useState({}),I=(t,e)=>{u(s=>({...s,[e]:t.currentTarget}))},c=t=>{u(e=>({...e,[t]:null}))},T=C.map((t,e)=>{var h;const s=(a.page-1)*a.page_size+(e+1),l=i.jsxs(i.Fragment,{children:[i.jsx(N,{sx:{px:"6px"},tabIndex:e,onClick:o=>I(o,t.id?`${t.id}`:""),"aria-controls":p[t!=null&&t.id?t.id:""]?"account-menu":void 0,"aria-haspopup":"true","aria-expanded":p[t!=null&&t.id?t.id:""]?"true":void 0,children:i.jsx(O,{size:16})}),i.jsxs(Q,{anchorEl:p[t!=null&&t.id?t.id:""],id:"account-menu",open:!!p[t!=null&&t.id?t.id:""],onClose:()=>c(t!=null&&t.id?t.id:""),PaperProps:{elevation:0,sx:{overflow:"visible",filter:"drop-shadow(0px 1px 2px rgba(185, 185, 185, 0.32))",mt:1.5,"& .MuiAvatar-root":{width:32,height:32,ml:-.5,mr:1},"&:before":{content:'""',display:"block",position:"absolute",top:0,right:14,width:10,height:10,bgcolor:"background.paper",transform:"translateY(-50%) rotate(45deg)",zIndex:0}}},transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[(m==null?void 0:m.indexOf("auth.change_group"))!==-1&&i.jsx(v,{onClick:()=>{c(t!=null&&t.id?t.id:""),d("/pages/settings/manage-profile/"+t.id)},children:i.jsxs(f,{direction:"row",alignItems:"center",spacing:2,children:[i.jsx(j,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),i.jsx(b,{children:"Edit"})]})}),i.jsx(v,{onClick:()=>{c(t!=null&&t.id?t.id:""),d("/pages/settings/datapermissions/"+t.id)},children:i.jsxs(f,{direction:"row",alignItems:"center",spacing:2,children:[i.jsx(j,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),i.jsx(b,{children:"Data Permissions"})]})})]})]}),A=(h=t==null?void 0:t.users)==null?void 0:h.map(o=>o==null?void 0:o.fullname).join(", ");return M(s,t.name,A??"",l)}),k=({search:t})=>{n(r({search:t||"",page:1,page_size:10}))},y=(t,e)=>{n(r({...a,search:"",page:e+1}))},E=t=>{n(r({...a,search:"",page:1,page_size:parseInt(t.target.value)}))};return x.useEffect(()=>{n(r({search:"",page:1,page_size:10})),g.setTitle("Manage Groups"),g.setSubtitle("Settings")},[]),i.jsxs(i.Fragment,{children:[i.jsx(H,{permissionPreFix:"auth",permissionPostFix:"group",navigateLink:"/pages/settings/manage-profile/0",showAddButton:!0,addButtonName:"Add Group",handleSearch:k,showFilterButton:!1,filteredData:a}),i.jsx(R,{count:P,columns:S,rows:T,loading:z,page:a.page,pageSize:a.page_size,handleChangePage:y,handleChangeRowsPerPage:E})]})};export{Ut as default};
