import{d as f,a as g,b as k,ob as v,r as D,j as e,I as S,aK as C,R as p,oh as F,oi as A,oj as u}from"./index-e6164346.js";import{c as w,b as E,u as q}from"./index.esm-0a041314.js";import{o as B}from"./yup-5fd5d57b.js";import"./GenericThumbnailView-80c6fd98.js";import{F as L}from"./FormInput-859198ec.js";import"./componentStyles-00385170.js";import"./ScrollableList-5a17e8f4.js";import"./TextArea-f5c200de.js";import{D as N}from"./Dialog-2e8a8e2e.js";import{D as P}from"./DialogTitle-8757f50f.js";import{D as R}from"./DialogContent-f10d6731.js";import{D as T}from"./DialogContentText-027be15d.js";import{D as U}from"./DialogActions-31bec80e.js";const I=({modal:n,closeModal:o,mastersName:d,editId:r,mastersValue:$})=>{const s=f(),{make:{selectedData:a,pageParams:l},system:{userAccessList:K}}=g(t=>({system:k(t),make:v(t)})),x=w().shape({name:E().required("Please enter your make name").trim()});D.useEffect(()=>{n?i({name:(a==null?void 0:a.name)||""}):i()},[n,a]);const{control:h,handleSubmit:b,reset:i}=q({resolver:B(x),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),j=t=>{if(r==null||r==0){const c={obj:{name:t.name},pageParams:l,clearDataFn:()=>{o(),s(u({})),i()},navigate:y=>{}};s(F(c))}else{const c={obj:{id:r,name:t.name},pageParams:l,clearDataFn:()=>{s(u({})),o(),i()},navigate:y=>{}};s(A(c))}};return e.jsx(e.Fragment,{children:e.jsxs(N,{open:n,onClose:(t,m)=>{m!=="backdropClick"&&o()},"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:[r==null||r==0?"Add ":"Update ",d,e.jsx(S,{onClick:o,children:e.jsx(C,{color:"white"})})]}),e.jsx(R,{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"}),r==null||r==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{I as A};
