import{d as f,a as g,b as k,ny as v,r as F,j as e,I as S,aI as C,R as p,nE as D,nF as A,nG as u}from"./index-858224db.js";import{c as w,b as E,u as q}from"./index.esm-241dec99.js";import{o as B}from"./yup-9213c3af.js";import"./GenericThumbnailView-2d7b7363.js";import{F as L}from"./FormInput-8eacbbd9.js";import"./componentStyles-107bd37e.js";import"./ScrollableList-bf78e54b.js";import"./TextArea-78cda1eb.js";import{D as N,a as P}from"./DialogContent-e06a39bc.js";import{D as R}from"./DialogTitle-6e616d34.js";import{D as T}from"./DialogContentText-a2775ca2.js";import{D as U}from"./DialogActions-825c19e9.js";const _=({modal:i,closeModal:o,mastersName:d,editId:t,mastersValue:$})=>{const s=f(),{make:{selectedData:a,pageParams:l},system:{userAccessList:G}}=g(r=>({system:k(r),make:v(r)})),x=w().shape({name:E().required("Please enter your make name").trim()});F.useEffect(()=>{i?n({name:(a==null?void 0:a.name)||""}):n()},[i,a]);const{control:h,handleSubmit:b,reset:n}=q({resolver:B(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({})),n()},navigate:y=>{}};s(D(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(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 ",d,e.jsx(S,{onClick:o,children:e.jsx(C,{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(L,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Make Name here...",control:h}),e.jsxs(U,{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{_ as A};
