import{b as y,a as f,g as v,ng as C,r as F,j as e,I as A,ef as D,J as m,nh as S,ni as w,nj as B}from"./index-d2b25495.js";import{c as k,b as E}from"./index.esm-3043d6d4.js";import{o as U}from"./yup-267e586f.js";import{u as q}from"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import{F as L}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{D as P,a as T}from"./DialogContent-cded694d.js";import{D as V}from"./DialogTitle-a145b392.js";import{D as $}from"./DialogContentText-43575e44.js";import{D as J}from"./DialogActions-7c802cc8.js";const _=({modal:n,closeModal:r,mastersName:u,editId:s,mastersValue:M})=>{const o=y(),{baseunit:{selectedData:t,pageParams:c},system:{userAccessList:N}}=f(a=>({system:v(a),baseunit:C(a)})),d=k({name:E().required("Please enter uom").trim()}),{control:x,handleSubmit:l,reset:p}=q({resolver:U(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}});F.useEffect(()=>{n?p({name:(t==null?void 0:t.name)||""}):p()},[n,t]);const h=a=>{const i={obj:{name:a.name},pageParams:c,clearDataFn:()=>{},navigate:g=>{}};o(S(i)),r(),o(w(""))},b=a=>{const i={obj:{id:s,name:a.name},pageParams:c,clearDataFn:()=>{},navigate:g=>{}};o(B(i)),r()};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:n,onClose: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 ",u,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:x})})})}),e.jsxs(J,{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:l(h),type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(m,{variant:"contained",onClick:l(b),type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})};export{_ as A};
