import{d as f,a as g,b as v,ol as C,r as D,j as e,I as F,aK as A,R as c,om as k,on as S,oo as w}from"./index-aa25c5ff.js";import{c as B,b as E,u as U}from"./index.esm-a7f661dc.js";import{o as q}from"./yup-72cc4918.js";import"./GenericThumbnailView-e0343bac.js";import{F as L}from"./FormInput-dc74a5d8.js";import"./componentStyles-e32842f3.js";import"./ScrollableList-9498bc37.js";import"./TextArea-d1a16eb1.js";import{D as P}from"./Dialog-049271f6.js";import{D as R}from"./DialogTitle-7a3842b8.js";import{D as T}from"./DialogContent-f207f33c.js";import{D as V}from"./DialogContentText-70face94.js";import{D as $}from"./DialogActions-2338d733.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(k(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(A,{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};
