import{b as f,a as g,h as v,j6 as C,r as F,j as e,I as A,ec as D,K as m,j7 as S,j8 as w,j9 as B}from"./index-43bf7a1c.js";import{c as k,b as E}from"./index.esm-f9e0a906.js";import{o as U}from"./yup-3b80ed10.js";import{u as q}from"./index.esm-0548c843.js";import"./componentStyles-4624000e.js";import{F as L}from"./FormInput-33b720a4.js";/* empty css                   */import"./ScrollableList-e19132c3.js";import{D as P,a as T}from"./DialogContent-d5902709.js";import{D as V}from"./DialogTitle-20dc6f66.js";import{D as $}from"./DialogContentText-abf03c9f.js";import{D as K}from"./DialogActions-d63c6496.js";const _=({modal:o,closeModal:r,mastersName:u,editId:s,mastersValue:M})=>{const i=f(),{baseunit:{selectedData:t,pageParams:c},system:{userAccessList:N}}=g(a=>({system:v(a),baseunit:C(a)})),d=k({name:E().required("Please enter uom").trim()}),{control:x,handleSubmit:l,reset:p}=q({resolver:U(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}});F.useEffect(()=>{o?p({name:(t==null?void 0:t.name)||""}):p()},[o,t]);const h=a=>{const n={obj:{name:a.name},pageParams:c,clearDataFn:()=>{},navigate:y=>{}};i(S(n)),r(),i(w(""))},j=a=>{const n={obj:{id:s,name:a.name},pageParams:c,clearDataFn:()=>{},navigate:y=>{}};i(B(n)),r()};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:o,onClose:r,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(V,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[s==null||s==0?"Add ":"Update ",u,e.jsx(A,{onClick:r,children:e.jsx(D,{color:"white"})})]}),e.jsx(T,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx($,{id:"alert-dialog-description",sx:{width:500},children:e.jsx("form",{style:{width:"100%"},children:e.jsx(L,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter UOM here...",control:x})})})}),e.jsxs(K,{sx:{p:2},children:[e.jsx(m,{onClick:r,variant:"outlined",color:"secondary",children:"Cancel"}),s==null||s==0?e.jsx(m,{variant:"contained",onClick:l(h),type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(m,{variant:"contained",onClick:l(j),type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})};export{_ as A};
