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-def636a4.js";import{c as w,b as E}from"./index.esm-eec4f448.js";import{o as $}from"./yup-c8535458.js";import{u as q}from"./index.esm-7d9d1491.js";import"./componentStyles-41382c67.js";import{F as B}from"./FormInput-8d872744.js";/* empty css                   */import"./ScrollableList-a550bc32.js";import{D as L,a as N}from"./DialogContent-0cb684b3.js";import{D as P}from"./DialogTitle-e2e75924.js";import{D as T}from"./DialogContentText-b2259947.js";import{D as U}from"./DialogActions-c4045764.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};
