import{d as j,a as f,b as v,qa as C,r as S,j as e,I as D,aL as F,R as p,qb as A,qc as q,qd as u}from"./index-e79f7aad.js";import{c as w,b as k,u as E}from"./index.esm-1ca67d65.js";import{o as L}from"./yup-96f14780.js";import"./GenericThumbnailView-8a83a30c.js";import{F as B}from"./FormInput-07daa19d.js";import"./componentStyles-7718fc5e.js";import"./ScrollableList-5929779e.js";import"./TextArea-ec29d1d5.js";import{D as P,a as R}from"./DialogContent-6a297cef.js";import{D as T}from"./DialogTitle-62595023.js";import{D as U}from"./DialogContentText-0c5306f9.js";import{D as $}from"./DialogActions-edd1d02f.js";const M=({modal:n,closeModal:o,mastersName:d,edit_Id:t,mastersValue:N})=>{const s=j(),{category:{selectedData:a,pageParams:l},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:(a==null?void 0:a.name)||""}):i()},[n,a]);const{control:y,handleSubmit:h,reset:i}=E({resolver:L(x),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),g=r=>{if(t==null||t==""){const m={obj:{name:r.name},pageParams:l,clearDataFn:()=>{o(),s(u({})),i()},navigate:b=>{}};s(A(m))}else{const m={obj:{id:t,name:r.name},pageParams:l,clearDataFn:()=>{o(),i(),s(u({}))},navigate:b=>{}};s(q(m))}};return e.jsx(e.Fragment,{children:e.jsxs(P,{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:[t==null||t==0?"Add ":"Update ",d,e.jsx(D,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(R,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(U,{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($,{sx:{p:2},children:[e.jsx(p,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),t==null||t==""?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};
