1import{m as Y,q as _,d as J,a2 as K,b as V,p as w,R as e,a4 as A,aC as X,P as Z,B as I,bY as ee,cj as se,c6 as ce,U as D,E as x,d4 as ae,gQ as te,b0 as re,T as oe,bG as i,fH as f}from"./index-CpcUj6vn.js";import{A as ne}from"./AccessGroupForm-JWkeOl5H.js";import"./ArrowBackRounded-DjrvSj4E.js";const le=Y(a=>({root:{flex:1,display:"flex",flexDirection:"column"},card:{width:"100%",marginBottom:a.spacing(2),display:"flex",flexDirection:"column"},cardContent:{display:"flex",justifyContent:"center"},accessGroupTableContainer:{padding:0},textField:{[a.breakpoints.up("sm")]:{minWidth:"40%"},[a.breakpoints.down("sm")]:{width:"100%"}},buttonContainer:{position:"fixed",bottom:a.spacing(3),right:a.spacing(3),zIndex:9999}})),de=()=>{const a=le(),p=_(),{customerId:l,accessGroupId:o}=J(),{error:d,success:m}=K(),t=V(),{pageHasChanges:k}=w(s=>s.session),{accessGroups:E,accessGroupsLoading:P}=w(s=>s.userAccess),[y,R]=e.useState(null),[b,T]=e.useState(!1),[$,h]=e.useState(!1),[H,v]=e.useState(null),u=o!=="new",F=e.useMemo(()=>E?.find(s=>s?.id===o),[E,o]),{mutate:M,loading:B}=A(({name:s,description:c,role:r,deny:n,selectedCustomerProducts:g,selectedUsers:C,selectedCustomerResources:G})=>({method:"POST",endpoint:"/useraccess/accessgroups",body:{name:s,description:c,role:r,deny:n,accessGroupCustomerProducts:g,accessGroupUsers:C,accessGroupResources:G}})),{mutate:L,loading:O}=A(({accessGroupId:s,name:c,description:r,role:n,deny:g,selectedCustomerProducts:C,selectedUsers:G,selectedCustomerResources:W})=>({method:"PATCH",endpoint:`/useraccess/accessgroups/${s}`,body:{name:c,description:r,role:n,deny:g,accessGroupCustomerProducts:C,accessGroupUsers:G,accessGroupResources:W}})),{mutate:U}=A(s=>({method:"DELETE",endpoint:`/useraccess/accessgroups/${s}`}));if(!F&&!P&&!H&&u)return e.createElement(X,{replace:!0,to:`/${l}/management/useraccess/accessgroups`});const j=async s=>{if(s.currentTarget.blur(),u){const{error:c,errorMessages:r}=await L({...y,accessGroupId:o});c?d(r):(m("AccessGroup updated"),await t({type:f}),await t(i(!1)))}else{const{payload:c,error:r,errorMessages:n}=await M({...y});!r&&c?.id?(m("AccessGroup created"),await t({type:f}),await t(i(!1)),v(c?.id??null),p.replace(`/${l}/management/useraccess/accessgroups/${c?.id}`)):d(n)}},q=async s=>{s.currentTarget.blur(),T(!b),await t(i(!1))},z=()=>{p.replace(`/${l}/management/useraccess/accessgroups`)},N=async()=>{const{error:s,errorMessages:c}=await U(o);s?d(c):(m("AccessGroup deleted"),await t({type:f}),await t(i(!1)),p.replace(`/${l}/management/useraccess/accessgroups`))},Q=s=>{R(s)},S=B||O;return e.createElement(Z,{className:a.root,title:"Access Group"},e.createElement(e.Fragment,null,k&&e.createElement("div",{className:a.buttonContainer},e.createElement(I,{variant:"contained",color:"secondary",onClick:q},e.createElement(ee,null))," ",e.createElement(I,{variant:"contained",color:"primary",onClick:j,disabled:S},S?e.createElement(se,{size:24,color:"inherit"}):e.createElement(ce,null))),e.createElement(ne,{accessGroupId:o??"new",title:u?"Access Group Info":"Create Access Group",headerAction:u?e.createElement(D,{title:"Delete Accessgroup"},e.createElement(x,{"aria-label":"Delete Accessgroup",onClick:()=>h(!0)},e.createElement(ae,null))):e.createElement(D,{title:"Cancel"},e.createElement(x,{"aria-label":"Cancel",onClick:z},e.createElement(te,null))),onChange:Q,resetForm:b}),e.createElement(re,{title:"Delete Accessgroup",open:$,onConfirm:N,onCancel:()=>h(!1)},e.createElement(oe,{variant:"body1"},"Are you sure you want to delete this Accessgroup?"))))};export{de as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.