import{r as s,eO as L,eP as P,j as e,bw as o,p as i,d as h,e as d,T as c,aQ as f,aR as T,c as y}from"./index-CK33qGU_.js";import{N as M}from"./NoData-CuLyR2Bg.js";import{u as N,g as O,r as S}from"./useProjectOptions-CUI0IhzU.js";const $=({roleChaining:t,isEditable:l})=>{const{data:a=[],isLoading:n}=N(),[g,r]=s.useState(!1),[u,{isLoading:m}]=L(),[R,{isLoading:C}]=P(),[w,b]=s.useState(t.projectId),[p,k]=s.useState(O(t.projectRole)),[j,v]=s.useState(t.cloudRole),D=s.useCallback(()=>{R({id:t.id})},[R,t.id]),I=s.useCallback(async()=>{await u({id:t.id,data:{projectRole:p,cloudRole:j}}),r(!1)},[j,p,t.id,u]);return!l||!g?e.jsxs(o.Row,{children:[e.jsx(o.Cell,{children:e.jsx(i,{width:"6px",children:t.id})}),l&&e.jsx(o.Cell,{children:e.jsx(i,{width:"85px",overflow:"hidden",children:t.projectName})}),e.jsx(o.Cell,{children:e.jsx(i,{width:"85px",children:t.projectRole})}),e.jsx(o.Cell,{children:e.jsx(i,{overflow:"hidden",children:t.cloudRole})}),l&&e.jsx(o.Cell,{pl:"0px",children:e.jsxs(h,{flexDirection:"row",children:[e.jsx(d,{icon:c.bin,intent:"ghost",tooltip:"delete",disabled:C,onClick:D}),e.jsx(d,{icon:c.edit,intent:"ghost",tooltip:"edit",onClick:()=>{r(!0)}})]})})]}):e.jsxs(o.Row,{children:[e.jsx(o.Cell,{children:e.jsx(i,{width:"6px",children:t.id})}),e.jsx(o.Cell,{children:e.jsx(f,{width:"max-content",value:`${w}`,options:a||[],placeholder:"pick a project",height:"fit-content",isDisabled:n,onChange:x=>b(+x)})}),e.jsx(o.Cell,{children:e.jsx(f,{width:"max-content",value:p,options:S,placeholder:"pick a role",onChange:k})}),e.jsx(o.Cell,{children:e.jsx(T,{width:"245",defaultValue:j,onChange:x=>v(x.target.value)})}),e.jsx(o.Cell,{pl:"0px",children:e.jsxs(h,{flexDirection:"row",children:[e.jsx(d,{intent:"ghost",icon:c.cross,tooltip:"cancel",disabled:m,onClick:()=>{r(!1)}}),e.jsx(d,{intent:"ghost",icon:c.validate,tooltip:"save",disabled:m,onClick:I})]})})]})},V=s.memo($),J=({roleChaining:t,isEditable:l})=>{const a=l?["id","project name","project role","cloud role",""]:["id","project role","cloud role",""];return e.jsx(h,{mt:"28px",sx:{th:{fontWeight:"700"}},children:t.length>0?e.jsx(o,{legend:a,middleColumn:l?3:2,children:t.map(n=>e.jsx(V,{roleChaining:n,isEditable:l},n.id))}):e.jsx(y,{my:"40px",children:e.jsx(M,{mainText:"No result found"})})})},W=s.memo(J);export{W as R};
