import{d as f,a as g,b as v,nH as C,r as F,j as e,I as A,aI as D,R as m,nI as k,nJ as S,nK as w}from"./index-858224db.js";import{c as B,b as E,u as U}from"./index.esm-241dec99.js";import{o as q}from"./yup-9213c3af.js";import"./GenericThumbnailView-2d7b7363.js";import{F as I}from"./FormInput-8eacbbd9.js";import"./componentStyles-107bd37e.js";import"./ScrollableList-bf78e54b.js";import"./TextArea-78cda1eb.js";import{D as L,a as P}from"./DialogContent-e06a39bc.js";import{D as R}from"./DialogTitle-6e616d34.js";import{D as T}from"./DialogContentText-a2775ca2.js";import{D as V}from"./DialogActions-825c19e9.js";const _=({modal:n,closeModal:r,mastersName:d,editId:s,mastersValue:$})=>{const o=f(),{baseunit:{selectedData:t,pageParams:l},system:{userAccessList:H}}=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(L,{open:n,onClose:(a,i)=>{i!=="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(A,{onClick:r,children:e.jsx(D,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(T,{id:"alert-dialog-description",sx:{width:500},children:e.jsx("form",{style:{width:"100%"},children:e.jsx(I,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter UOM here...",control:h})})})}),e.jsxs(V,{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};
