import{d as f,a as g,b as k,oc as v,r as D,j as e,I as S,aK as C,R as p,oi as F,oj as A,ok as u}from"./index-aa25c5ff.js";import{c as w,b as E,u as q}from"./index.esm-a7f661dc.js";import{o as B}from"./yup-72cc4918.js";import"./GenericThumbnailView-e0343bac.js";import{F as L}from"./FormInput-dc74a5d8.js";import"./componentStyles-e32842f3.js";import"./ScrollableList-9498bc37.js";import"./TextArea-d1a16eb1.js";import{D as N}from"./Dialog-049271f6.js";import{D as P}from"./DialogTitle-7a3842b8.js";import{D as R}from"./DialogContent-f207f33c.js";import{D as T}from"./DialogContentText-70face94.js";import{D as U}from"./DialogActions-2338d733.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};
