import{d as f,a as g,b as v,py as C,r as A,j as e,I as F,aL as D,R as p,pz as k,pA as B,pB as S}from"./index-e79f7aad.js";import{c as w,b as E,u as U}from"./index.esm-1ca67d65.js";import{o as L}from"./yup-96f14780.js";import"./GenericThumbnailView-8a83a30c.js";import{F as q}from"./FormInput-07daa19d.js";import"./componentStyles-7718fc5e.js";import"./ScrollableList-5929779e.js";import"./TextArea-ec29d1d5.js";import{D as P,a as R}from"./DialogContent-6a297cef.js";import{D as T}from"./DialogTitle-62595023.js";import{D as V}from"./DialogContentText-0c5306f9.js";import{D as $}from"./DialogActions-edd1d02f.js";const _=({modal:o,closeModal:r,mastersName:d,editId:s,mastersValue:z})=>{const i=f(),{baseunit:{selectedData:t,pageParams:m},system:{userAccessList:M}}=g(a=>({system:v(a),baseunit:C(a)})),x=w({name:E().required("Please enter uom").trim()}),{control:h,handleSubmit:l,reset:u}=U({resolver:L(x),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}});A.useEffect(()=>{o?u({name:(t==null?void 0:t.name)||""}):u()},[o,t]);const b=a=>{const c={obj:{name:a.name},pageParams:m,clearDataFn:()=>{},navigate:y=>{}};i(k(c)),r(),i(B(""))},j=a=>{const c={obj:{id:s,name:a.name},pageParams:m,clearDataFn:()=>{},navigate:y=>{}};i(S(c)),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(T,{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(D,{color:"white"})})]}),e.jsx(R,{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(q,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter UOM here...",control:h})})})}),e.jsxs($,{sx:{p:2},children:[e.jsx(p,{onClick:r,variant:"outlined",color:"secondary",children:"Cancel"}),s==null||s==0?e.jsx(p,{variant:"contained",onClick:l(b),type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(p,{variant:"contained",onClick:l(j),type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})};export{_ as A};
