import{d as f,a as g,b as v,ok as C,r as D,j as e,I as F,aK as k,R as c,ol as A,om as S,on as w}from"./index-e6164346.js";import{c as B,b as E,u as U}from"./index.esm-0a041314.js";import{o as q}from"./yup-5fd5d57b.js";import"./GenericThumbnailView-80c6fd98.js";import{F as L}from"./FormInput-859198ec.js";import"./componentStyles-00385170.js";import"./ScrollableList-5a17e8f4.js";import"./TextArea-f5c200de.js";import{D as P}from"./Dialog-2e8a8e2e.js";import{D as R}from"./DialogTitle-8757f50f.js";import{D as T}from"./DialogContent-f10d6731.js";import{D as V}from"./DialogContentText-027be15d.js";import{D as $}from"./DialogActions-31bec80e.js";const ee=({modal:o,closeModal:r,mastersName:d,editId:s,mastersValue:K})=>{const i=f(),{baseunit:{selectedData:t,pageParams:l},system:{userAccessList:M}}=g(a=>({system:v(a),baseunit:C(a)})),x=B({name:E().required("Please enter uom").trim()}),{control:h,handleSubmit:p,reset:u}=U({resolver:q(x),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}});D.useEffect(()=>{o?u({name:(t==null?void 0:t.name)||""}):u()},[o,t]);const b=a=>{const m={obj:{name:a.name},pageParams:l,clearDataFn:()=>{},navigate:y=>{}};i(A(m)),r(),i(S(""))},j=a=>{const m={obj:{id:s,name:a.name},pageParams:l,clearDataFn:()=>{},navigate:y=>{}};i(w(m)),r()};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:o,onClose:(a,n)=>{n!=="backdropClick"&&r()},"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:[s==null||s==0?"Add ":"Update ",d,e.jsx(F,{onClick:r,children:e.jsx(k,{color:"white"})})]}),e.jsx(T,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(V,{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:h})})})}),e.jsxs($,{sx:{p:2},children:[e.jsx(c,{onClick:r,variant:"outlined",color:"secondary",children:"Cancel"}),s==null||s==0?e.jsx(c,{variant:"contained",onClick:p(b),type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(c,{variant:"contained",onClick:p(j),type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})};export{ee as A};
