import{r as l,p as e,a_ as p,b0 as f,b1 as j,b2 as b,b3 as g,b5 as D,W as y,b8 as v,I as c}from"./index-C_ue0cEN.js";const N=({role:a,open:m,onOpenChange:i,onSubmit:u})=>{const[r,o]=l.useState(!1),[s,t]=l.useState("");l.useEffect(()=>{a&&t(a.name)},[a]);const h=async n=>{if(n.preventDefault(),!(!s.trim()||!a)){o(!0);try{await u(a.id,{name:s.trim()}),i(!1)}catch(x){console.error("Failed to update role:",x)}finally{o(!1)}}},d=()=>{a&&t(a.name),i(!1)};return e.jsx(p,{open:m,onOpenChange:d,children:e.jsxs(f,{className:"sm:max-w-md",children:[e.jsxs(j,{children:[e.jsx(b,{children:"Edit Role"}),e.jsx(g,{children:"Update the role name"})]}),e.jsxs("form",{onSubmit:h,children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"role-name",children:"Role Name *"}),e.jsx(y,{id:"role-name",value:s,onChange:n=>t(n.target.value),placeholder:"Enter role name",required:!0})]})}),e.jsxs(v,{className:"mt-6",children:[e.jsx(c,{type:"button",variant:"outline",onClick:d,children:"Cancel"}),e.jsx(c,{type:"submit",disabled:r||!s.trim(),children:r?"Updating...":"Update Role"})]})]})]})})};export{N as default};
