import{d as f,a as g,b as k,o1 as v,r as S,j as e,I as C,aK as D,R as p,o7 as F,o8 as A,o9 as u}from"./index-6c48ebe4.js";import{c as w,b as E,u as q}from"./index.esm-fd3369ba.js";import{o as B}from"./yup-75ac0470.js";import"./GenericThumbnailView-e18774c4.js";import{F as L}from"./FormInput-345d040e.js";import"./componentStyles-1dd5fe29.js";import"./ScrollableList-e9cb113e.js";import"./TextArea-4432195b.js";import{D as N,a as P}from"./DialogContent-2975c76a.js";import{D as R}from"./DialogTitle-6235c46a.js";import{D as T}from"./DialogContentText-928ca488.js";import{D as U}from"./DialogActions-aa83bc6c.js";const _=({modal:n,closeModal:o,mastersName:d,editId:t,mastersValue:$})=>{const s=f(),{make:{selectedData:a,pageParams:l},system:{userAccessList:K}}=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}=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({})),i()},navigate:y=>{}};s(F(c))}else{const c={obj:{id:t,name:r.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:(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(C,{onClick:o,children:e.jsx(D,{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};
