import{d as f,a as g,b as k,pp as v,r as S,j as e,I as C,aL as D,R as c,pv as F,pw as A,px as u}from"./index-e79f7aad.js";import{c as w,b as E,u as L}from"./index.esm-1ca67d65.js";import{o as q}from"./yup-96f14780.js";import"./GenericThumbnailView-8a83a30c.js";import{F as B}from"./FormInput-07daa19d.js";import"./componentStyles-7718fc5e.js";import"./ScrollableList-5929779e.js";import"./TextArea-ec29d1d5.js";import{D as N,a as P}from"./DialogContent-6a297cef.js";import{D as R}from"./DialogTitle-62595023.js";import{D as T}from"./DialogContentText-0c5306f9.js";import{D as U}from"./DialogActions-edd1d02f.js";const _=({modal:n,closeModal:o,mastersName:x,editId:t,mastersValue:$})=>{const s=f(),{make:{selectedData:a,pageParams:l},system:{userAccessList:M}}=g(r=>({system:k(r),make:v(r)})),d=w().shape({name:E().required("Please enter your make name").trim()});S.useEffect(()=>{n?i({name:(a==null?void 0:a.name)||""}):i()},[n,a]);const{control:h,handleSubmit:b,reset:i}=L({resolver:q(d),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),j=r=>{if(t==null||t==0){const p={obj:{name:r.name},pageParams:l,clearDataFn:()=>{o(),s(u({})),i()},navigate:y=>{}};s(F(p))}else{const p={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{s(u({})),o(),i()},navigate:y=>{}};s(A(p))}};return e.jsx(e.Fragment,{children:e.jsxs(N,{open:n,onClose:(r,m)=>{m!=="backdropClick"&&o()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(R,{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 ",x,e.jsx(C,{onClick:o,children:e.jsx(D,{color:"white"})})]}),e.jsx(P,{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:b(j),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:o,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};
