import{b as y,a as g,g as k,nc as v,r as S,j as e,I as A,ef as D,J as c,nd as F,ne as C,nf as p}from"./index-d2b25495.js";import{c as w,b as E}from"./index.esm-3043d6d4.js";import{o as $}from"./yup-267e586f.js";import{u as q}from"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import{F as B}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{D as L,a as N}from"./DialogContent-cded694d.js";import{D as P}from"./DialogTitle-a145b392.js";import{D as T}from"./DialogContentText-43575e44.js";import{D as U}from"./DialogActions-7c802cc8.js";const _=({modal:i,closeModal:r,mastersName:u,editId:t,mastersValue:z})=>{const s=y(),{make:{selectedData:a,pageParams:l},system:{userAccessList:J}}=g(o=>({system:k(o),make:v(o)})),d=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:h,handleSubmit:x,reset:n}=q({resolver:$(d),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:f=>{}};s(F(m))}else{const m={obj:{id:t,name:o.name},pageParams:l,clearDataFn:()=>{s(p({})),r(),n()},navigate:f=>{}};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:x(b),children:[e.jsx(B,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Make Name here...",control:h}),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};
