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-5768b108.js";import{T as R}from"./index-fcf73630.js";import{T as H}from"./TopComponent-a10f4baf.js";import{M as Q}from"./Menu-7988a333.js";import{M as v}from"./MenuItem-51065bfa.js";import"./TableCell-73fa51e5.js";import"./TableRow-3593e946.js";import"./index-bed7b08c.js";import"./useMediaQuery-493fa36e.js";import"./TableHead-1c4bab1f.js";import"./createSvgIcon-51b522b8.js";import"./TablePagination-e6e264e7.js";import"./Toolbar-96b35f70.js";import"./Select-3950b24e.js";import"./OutlinedInput-8a98392b.js";import"./useFormControl-e91ce3d1.js";import"./isHostComponent-73d6e646.js";import"./useControlled-821282b7.js";import"./KeyboardArrowRight-56dea4db.js";import"./LastPage-f21d7153.js";import"./yup-7ddf262a.js";import"./index.esm-4803c918.js";import"./CustomDatepicker-c97efda4.js";import"./floating-ui.dom-cd6c919d.js";import"./InputAdornment-82d0c147.js";import"./index-c58b1ae1.js";import"./index-4ca9e290.js";import"./InputLabel-bfa922b7.js";import"./index-42cce9d5.js";import"./SectionDivider-bc494fef.js";import"./resolveProps-5b0bdb14.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-9a8473c9.js";import"./PageBreadCrumb-5c3ff2bc.js";import"./PageMetaData-84e26924.js";import"./Breadcrumbs-37f99f42.js";import"./useSlotProps-ed538db1.js";import"./Link-a5e92257.js";import"./ScrollableList-c8e84a4e.js";import"./List-2cd167d2.js";import"./index.esm-85e2fec5.js";import"./TextField-265270c2.js";import"./FormControl-47bb025d.js";import"./FilterOutlined-52596c0e.js";import"./AntdIcon-3a079263.js";import"./slicedToArray-f5e6f6d2.js";import"./defineProperty-83f36300.js";import"./objectSpread2-d5d2b678.js";import"./Grow-c21b912f.js";import"./dividerClasses-a2ef427b.js";import"./listItemTextClasses-3e91d186.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};
