import{d as f,a as g,b as k,pA as v,r as S,j as e,I as A,aM as C,U as c,pG as D,pH as F,pI as u}from"./index-c3f592b2.js";import{c as w,b as E,u as U}from"./index.esm-70dd1c06.js";import{o as q}from"./yup-abb4a026.js";import"./GenericThumbnailView-9f1d2f81.js";import{F as B}from"./FormInput-adbf55b1.js";import"./componentStyles-b8fcedb5.js";import"./ScrollableList-ecbfc0f3.js";import"./TextArea-674a9ec6.js";import{D as L,a as M}from"./DialogContent-b7fc1c43.js";import{D as N}from"./DialogTitle-5d3e2030.js";import{D as P}from"./DialogContentText-c3e782dc.js";import{D as T}from"./DialogActions-6e00f4f1.js";const _=({modal:n,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()});S.useEffect(()=>{n?i({name:(a==null?void 0:a.name)||""}):i()},[n,a]);const{control:h,handleSubmit:b,reset:i}=U({resolver:q(x),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),j=r=>{if(t==null||t==0){const p={obj:{name:r.name},pageParams:l,clearDataFn:()=>{o(),s(u({})),i()},navigate:y=>{}};s(D(p))}else{const p={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{s(u({})),o(),i()},navigate:y=>{}};s(F(p))}};return e.jsx(e.Fragment,{children:e.jsxs(L,{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(A,{onClick:o,children:e.jsx(C,{color:"white"})})]}),e.jsx(M,{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(B,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Make Name here...",control:h}),e.jsxs(T,{sx:{p:2},children:[e.jsx(c,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),t==null||t==0?e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
