import{d as j,a as f,b as v,o_ as C,r as S,j as e,I as D,aK as F,R as p,o$ as A,p0 as w,p1 as u}from"./index-5ae5cc5e.js";import{c as k,b as E,u as $}from"./index.esm-bd37e938.js";import{o as q}from"./yup-86a48159.js";import"./GenericThumbnailView-fac7773c.js";import{F as B}from"./FormInput-77541d96.js";import"./componentStyles-7d84c389.js";import"./ScrollableList-2ee889f8.js";import"./TextArea-20f097f8.js";import{D as L,a as P}from"./DialogContent-e2578cbd.js";import{D as R}from"./DialogTitle-4a5aec12.js";import{D as T}from"./DialogContentText-bc10bf8d.js";import{D as U}from"./DialogActions-ad26e3d6.js";const M=({modal:n,closeModal:o,mastersName:d,edit_Id:a,mastersValue:K})=>{const s=j(),{category:{selectedData:t,pageParams:l},system:{userAccessList:N}}=f(r=>({system:v(r),category:C(r)})),x=k().shape({name:E().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}=$({resolver:q(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:l,clearDataFn:()=>{o(),s(u({})),i()},navigate:b=>{}};s(A(m))}else{const m={obj:{id:a,name:r.name},pageParams:l,clearDataFn:()=>{o(),i(),s(u({}))},navigate:b=>{}};s(w(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(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:[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(T,{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(U,{sx:{p:2},children:[e.jsx(p,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),a==null||a==""?e.jsx(p,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(p,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{M as A};
