import{d as f,a as g,b as k,m_ as v,r as S,j as e,I as C,ax as D,z as p,n4 as F,n5 as A,n6 as u}from"./index-d895656a.js";import{c as w,b as E,u as q}from"./index.esm-1087b2f3.js";import{o as B}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as L}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as N,a as P}from"./DialogContent-4ce43512.js";import{D as T}from"./DialogTitle-738ca272.js";import{D as U}from"./DialogContentText-8b9b0e0c.js";import{D as $}from"./DialogActions-7b82f6f6.js";const Z=({modal:i,closeModal:o,mastersName:x,editId:t,mastersValue:z})=>{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(()=>{i?n({name:(a==null?void 0:a.name)||""}):n()},[i,a]);const{control:h,handleSubmit:b,reset:n}=q({resolver:B(d),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({})),n()},navigate:y=>{}};s(F(c))}else{const c={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{s(u({})),o(),n()},navigate:y=>{}};s(A(c))}};return e.jsx(e.Fragment,{children:e.jsxs(N,{open:i,onClose:(r,m)=>{m!=="backdropClick"&&o()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(T,{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(U,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:b(j),children:[e.jsx(L,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Make Name here...",control:h}),e.jsxs($,{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{Z as A};
