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-6fe66247.js";import{T as R}from"./index-2cc408cd.js";import{T as H}from"./TopComponent-3a5f48d0.js";import{M as Q}from"./Menu-e61076f9.js";import{M as v}from"./MenuItem-cae4b005.js";import"./TableCell-1aea1cc4.js";import"./TableRow-3949f515.js";import"./index-bf51d29c.js";import"./useMediaQuery-0f3d61e0.js";import"./TableHead-d8cbb45f.js";import"./createSvgIcon-00102b53.js";import"./TablePagination-5e52cd9b.js";import"./Toolbar-928aa284.js";import"./Select-f9dfa240.js";import"./OutlinedInput-982baeac.js";import"./useFormControl-35c6f1af.js";import"./isHostComponent-73d6e646.js";import"./useControlled-e803b382.js";import"./KeyboardArrowRight-8a542f89.js";import"./LastPage-fa4056a6.js";import"./yup-ef931f05.js";import"./index.esm-8dc7c617.js";import"./CustomDatepicker-8082706c.js";import"./floating-ui.dom-cd6c919d.js";import"./InputAdornment-33eb10d0.js";import"./index-25f54021.js";import"./index-b6605ad3.js";import"./InputLabel-76d7f8cb.js";import"./index-b6aec95e.js";import"./SectionDivider-ea552de1.js";import"./resolveProps-d8ef25a0.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-a478ed92.js";import"./PageBreadCrumb-90e2746d.js";import"./PageMetaData-4821a42d.js";import"./Breadcrumbs-52f929ae.js";import"./useSlotProps-d14db7f9.js";import"./Link-de7e0135.js";import"./ScrollableList-0f8e556e.js";import"./List-11a0d6f8.js";import"./index.esm-34c2a639.js";import"./TextField-0748ea02.js";import"./FormControl-cc4d9109.js";import"./FilterOutlined-e90fa981.js";import"./AntdIcon-5ec370b1.js";import"./slicedToArray-f5e6f6d2.js";import"./defineProperty-83f36300.js";import"./objectSpread2-dd5dc5f3.js";import"./Grow-b68a569b.js";import"./dividerClasses-9c506d69.js";import"./listItemTextClasses-5758b05f.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};
