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-60a3c753.js";import{c as k,b as E}from"./index.esm-62d6b2f7.js";import{o as U}from"./yup-92678dde.js";import{u as q}from"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import{F as L}from"./FormInput-74e2c4d2.js";/* empty css                   */import"./ScrollableList-1962b023.js";import{D as P,a as T}from"./DialogContent-89e21f2e.js";import{D as V}from"./DialogTitle-fe69da5c.js";import{D as $}from"./DialogContentText-6688bd59.js";import{D as K}from"./DialogActions-e754942c.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};
