import{d as j,a as f,b as v,ql as C,r as S,j as e,I as D,aM as F,U as l,qm as A,qn as q,qo as u}from"./index-60657852.js";import{c as w,b as k,u as E}from"./index.esm-509a598d.js";import{o as U}from"./yup-75ad371b.js";import"./GenericThumbnailView-f8b17afa.js";import{F as B}from"./FormInput-6b018fe9.js";import"./componentStyles-19763afb.js";import"./ScrollableList-ef4c85dc.js";import"./TextArea-d897dbf9.js";import{D as L,a as P}from"./DialogContent-d5183bd6.js";import{D as T}from"./DialogTitle-66c21479.js";import{D as $}from"./DialogContentText-e3f3f7dd.js";import{D as N}from"./DialogActions-1dfa5a01.js";const M=({modal:n,closeModal:o,mastersName:d,edit_Id:a,mastersValue:R})=>{const s=j(),{category:{selectedData:t,pageParams:p},system:{userAccessList:V}}=f(r=>({system:v(r),category:C(r)})),x=w().shape({name:k().required("Please enter your category name").trim()});S.useEffect(()=>{n?i({name:(t==null?void 0:t.name)||""}):i()},[n,t]);const{control:y,handleSubmit:h,reset:i}=E({resolver:U(x),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),g=r=>{if(a==null||a==""){const m={obj:{name:r.name},pageParams:p,clearDataFn:()=>{o(),s(u({})),i()},navigate:b=>{}};s(A(m))}else{const m={obj:{id:a,name:r.name},pageParams:p,clearDataFn:()=>{o(),i(),s(u({}))},navigate:b=>{}};s(q(m))}};return e.jsx(e.Fragment,{children:e.jsxs(L,{open:n,onClose:(r,c)=>{c!=="backdropClick"&&o()},"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:[a==null||a==0?"Add ":"Update ",d,e.jsx(D,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(P,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx($,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(g),children:[e.jsx(B,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Category here...",control:y}),e.jsxs(N,{sx:{p:2},children:[e.jsx(l,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),a==null||a==""?e.jsx(l,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(l,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{M as A};
