import{b as f,a as g,h as k,ng as v,r as S,j as e,I as A,ec as D,K as c,nh as F,ni as C,nj as p}from"./index-60a3c753.js";import{c as w,b as E}from"./index.esm-62d6b2f7.js";import{o as $}from"./yup-92678dde.js";import{u as q}from"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import{F as B}from"./FormInput-74e2c4d2.js";/* empty css                   */import"./ScrollableList-1962b023.js";import{D as L,a as N}from"./DialogContent-89e21f2e.js";import{D as P}from"./DialogTitle-fe69da5c.js";import{D as T}from"./DialogContentText-6688bd59.js";import{D as U}from"./DialogActions-e754942c.js";const _=({modal:i,closeModal:r,mastersName:u,editId:t,mastersValue:z})=>{const s=f(),{make:{selectedData:a,pageParams:l},system:{userAccessList:K}}=g(o=>({system:k(o),make:v(o)})),h=w().shape({name:E().required("Please enter your make name").trim().matches(/^[a-zA-Z0-9 ]*$/,"make name should not contain special characters")});S.useEffect(()=>{i?n({name:(a==null?void 0:a.name)||""}):n()},[i,a]);const{control:x,handleSubmit:d,reset:n}=q({resolver:$(h),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),j=o=>{if(t==null||t==0){const m={obj:{name:o.name},pageParams:l,clearDataFn:()=>{r(),s(p({})),n()},navigate:y=>{}};s(F(m))}else{const m={obj:{id:t,name:o.name},pageParams:l,clearDataFn:()=>{s(p({})),r(),n()},navigate:y=>{}};s(C(m))}};return e.jsx(e.Fragment,{children:e.jsxs(L,{open:i,onClose:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(P,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[t==null||t==0?"Add ":"Update ",u,e.jsx(A,{onClick:r,children:e.jsx(D,{color:"white"})})]}),e.jsx(N,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(T,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:d(j),children:[e.jsx(B,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Make Name here...",control:x}),e.jsxs(U,{sx:{p:2},children:[e.jsx(c,{onClick:r,variant:"outlined",color:"secondary",children:"Cancel"}),t==null||t==0?e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
