import{d as f,a as g,b as v,pJ as C,r as F,j as e,I as A,aM as D,U as p,pK as k,pL as S,pM as w}from"./index-60657852.js";import{c as B,b as U,u as E}from"./index.esm-509a598d.js";import{o as L}from"./yup-75ad371b.js";import"./GenericThumbnailView-f8b17afa.js";import{F as M}from"./FormInput-6b018fe9.js";import"./componentStyles-19763afb.js";import"./ScrollableList-ef4c85dc.js";import"./TextArea-d897dbf9.js";import{D as q,a as P}from"./DialogContent-d5183bd6.js";import{D as T}from"./DialogTitle-66c21479.js";import{D as V}from"./DialogContentText-e3f3f7dd.js";import{D as $}from"./DialogActions-1dfa5a01.js";const _=({modal:o,closeModal:r,mastersName:d,editId:s,mastersValue:J})=>{const i=f(),{baseunit:{selectedData:t,pageParams:m},system:{userAccessList:K}}=g(a=>({system:v(a),baseunit:C(a)})),x=B({name:U().required("Please enter uom").trim()}),{control:h,handleSubmit:l,reset:u}=E({resolver:L(x),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}});F.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(S(""))},j=a=>{const c={obj:{id:s,name:a.name},pageParams:m,clearDataFn:()=>{},navigate:y=>{}};i(w(c)),r()};return e.jsx(e.Fragment,{children:e.jsxs(q,{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(A,{onClick:r,children:e.jsx(D,{color:"white"})})]}),e.jsx(P,{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(M,{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};
