import{d as f,a as g,b as v,n7 as C,r as F,j as e,I as A,ax as D,z as m,n8 as k,n9 as S,na as w}from"./index-4dfc510b.js";import{c as B,b as E,u as U}from"./index.esm-0a454763.js";import{o as q}from"./yup-80def618.js";import"./GenericThumbnailView-6256cad7.js";import{F as L}from"./FormInput-f887e69c.js";import"./componentStyles-df94248d.js";import"./ScrollableList-bef4a518.js";import"./TextArea-a0cc14f3.js";import{D as P,a as T}from"./DialogContent-3bf4ff27.js";import{D as V}from"./DialogTitle-248b1818.js";import{D as $}from"./DialogContentText-a6ab23a2.js";import{D as z}from"./DialogActions-49286e71.js";const _=({modal:n,closeModal:r,mastersName:d,editId:s,mastersValue:M})=>{const o=f(),{baseunit:{selectedData:t,pageParams:l},system:{userAccessList:N}}=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:""}});F.useEffect(()=>{n?u({name:(t==null?void 0:t.name)||""}):u()},[n,t]);const b=a=>{const c={obj:{name:a.name},pageParams:l,clearDataFn:()=>{},navigate:y=>{}};o(k(c)),r(),o(S(""))},j=a=>{const c={obj:{id:s,name:a.name},pageParams:l,clearDataFn:()=>{},navigate:y=>{}};o(w(c)),r()};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:n,onClose:(a,i)=>{i!=="backdropClick"&&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 ",d,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:h})})})}),e.jsxs(z,{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:p(b),type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(m,{variant:"contained",onClick:p(j),type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})};export{_ as A};
