import{R as x,r as i,j as e,aH as j,aJ as p,aK as f,aL as g,aM as C,aO as R,q as D,aR as y,i as c}from"./index-Dh1NdHQs.js";const N=({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(f,{children:[e.jsx(g,{children:"Create New Role"}),e.jsx(C,{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(R,{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(y,{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(N);export{v as default};
