import{j as o}from"./vendor-mui-69397583.js";import{R as f}from"./RoleForm-cc251eba.js";import{O as r,Q as n}from"./index-c62ac197.js";import{b as y}from"./RoleService-7008da2c.js";import{f as R,r as w}from"./vendor-react-ece1c85f.js";const g=s=>{const{onDrawerClose:i,footerWidth:d}=s;R(),w.useState(!1);const p=async e=>await y(e),m=async(e,u)=>{var a,c;e.roleType="Operation";const h={name:e.name??"",description:e.description??"",roleType:e.roleType};try{const t=await p(h);t.success?(r.push(o.jsx(n,{title:"Success",type:"success",duration:2500,children:"Role Successfully Added"}),{placement:"top-center"}),s.onAddNew()):r.push(o.jsx(n,{title:"Error",type:"danger",duration:2500,children:t.message}),{placement:"top-center"})}catch(t){r.push(o.jsx(n,{title:"Error",type:"danger",duration:2500,children:((c=(a=t==null?void 0:t.response)==null?void 0:a.data)==null?void 0:c.message)||"Something went wrong"}),{placement:"top-center"}),s.onAddNew()}},l=()=>{i()};return o.jsx(o.Fragment,{children:o.jsx(f,{type:"new",footerWidth:d,onFormSubmit:m,onDiscard:l})})},E=g;export{E as R};
