import{b as f,a as g,h as v,iW as C,r as F,j as e,I as A,ec as D,K as m,iX as S,iY as w,iZ as B}from"./index-76d4793e.js";import{c as k,b as E}from"./index.esm-ad8a7c9f.js";import{o as U}from"./yup-688ec4f6.js";import{u as q}from"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import{F as L}from"./FormInput-8f40ded1.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import{D as P,a as T}from"./DialogContent-7bd8dd8f.js";import{D as V}from"./DialogTitle-71dd5b3a.js";import{D as X}from"./DialogContentText-7642f81f.js";import{D as $}from"./DialogActions-5a5e1db9.js";const _=({modal:i,closeModal:r,mastersName:u,editId:s,mastersValue:K})=>{const o=f(),{baseunit:{selectedData:t,pageParams:c},system:{userAccessList:M}}=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(()=>{i?p({name:(t==null?void 0:t.name)||""}):p()},[i,t]);const h=a=>{const n={obj:{name:a.name},pageParams:c,clearDataFn:()=>{},navigate:y=>{}};o(S(n)),r(),o(w(""))},b=a=>{const n={obj:{id:s,name:a.name},pageParams:c,clearDataFn:()=>{},navigate:y=>{}};o(B(n)),r()};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:i,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(X,{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($,{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(b),type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})};export{_ as A};
