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