import{b as f,a as g,h as k,n6 as v,r as S,j as e,I as A,ec as D,K as c,n7 as F,n8 as C,n9 as p}from"./index-76d4793e.js";import{c as w,b as E}from"./index.esm-ad8a7c9f.js";import{o as $}from"./yup-688ec4f6.js";import{u as q}from"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import{F as B}from"./FormInput-8f40ded1.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import{D as L,a as N}from"./DialogContent-7bd8dd8f.js";import{D as P}from"./DialogTitle-71dd5b3a.js";import{D as T}from"./DialogContentText-7642f81f.js";import{D as U}from"./DialogActions-5a5e1db9.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:""}}),b=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(b),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};
