import{j as t}from"./vendor-mui-69397583.js";import{U as h}from"./UserForm-31fdd3b3.js";import{ab as y,O as i,Q as c}from"./index-c62ac197.js";import{c as g}from"./UserService-047aef51.js";import{f}from"./vendor-react-ece1c85f.js";const w=r=>{const{footerWidth:m}=r;f();const{auth:a}=y.getState(),p=async e=>{var n,s;const l={firstName:e.firstName,lastName:e.lastName,email:e.email,password:e.password,role:e.role.value,loginType:e.loginType.value,brLocationId:e.brLocationId,tenantId:a.session.tenantId??"",phone:(e==null?void 0:e.phone)??null,accountId:((n=e==null?void 0:e.accountId)==null?void 0:n.value)??null,entityId:((s=e==null?void 0:e.entityId)==null?void 0:s.value)??null};return await g(l)},u=async(e,l)=>{var o,n;try{const s=await p(e);s.success&&s.message!=="A user with this email address already exists"?(i.push(t.jsx(c,{title:"Success",type:"success",duration:2500,children:"User Successfully Added"}),{placement:"top-center"}),r.onAddNew()):i.push(t.jsx(c,{title:"Error",type:"danger",duration:2500,children:s.message}),{placement:"top-center"})}catch(s){i.push(t.jsx(c,{title:"Error",type:"danger",duration:2500,children:((n=(o=s==null?void 0:s.response)==null?void 0:o.data)==null?void 0:n.message)||"Something went wrong. please try again!"}),{placement:"top-center"})}},d=()=>{r.onClose()};return t.jsx(t.Fragment,{children:t.jsx(h,{type:"new",footerWidth:m,onFormSubmit:u,onDiscard:d})})},S=w;export{S as U};
