import{d as f,a as g,b as k,oT as v,r as S,j as e,I as C,aL as D,R as p,oZ as F,o_ as A,o$ as u}from"./index-952e178b.js";import{c as w,b as E,u as L}from"./index.esm-6feddb16.js";import{o as T}from"./yup-d92565dd.js";import"./GenericThumbnailView-4e535459.js";import{F as $}from"./FormInput-8320115a.js";import"./componentStyles-00160cc0.js";import"./ScrollableList-cd5816a8.js";import"./TextArea-ce7716c9.js";import{D as q,a as B}from"./DialogContent-4facb916.js";import{D as N}from"./DialogTitle-3aa960f8.js";import{D as P}from"./DialogContentText-54d95680.js";import{D as R}from"./DialogActions-bd200b72.js";const Y=({modal:n,closeModal:o,mastersName:d,editId:t,mastersValue:U})=>{const s=f(),{make:{selectedData:a,pageParams:l},system:{userAccessList:M}}=g(r=>({system:k(r),make:v(r)})),x=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:T(x),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),j=r=>{if(t==null||t==0){const c={obj:{name:r.name},pageParams:l,clearDataFn:()=>{o(),s(u({})),i()},navigate:y=>{}};s(F(c))}else{const c={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{s(u({})),o(),i()},navigate:y=>{}};s(A(c))}};return e.jsx(e.Fragment,{children:e.jsxs(q,{open:n,onClose:(r,m)=>{m!=="backdropClick"&&o()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(N,{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 ",d,e.jsx(C,{onClick:o,children:e.jsx(D,{color:"white"})})]}),e.jsx(B,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(P,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:b(j),children:[e.jsx($,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Make Name here...",control:h}),e.jsxs(R,{sx:{p:2},children:[e.jsx(p,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),t==null||t==0?e.jsx(p,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(p,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{Y as A};
