import{d as j,a as f,b as v,pE as C,r as F,j as e,I as S,aL as D,R as p,pF as A,pG as w,pH as u}from"./index-952e178b.js";import{c as E,b as k,u as L}from"./index.esm-6feddb16.js";import{o as q}from"./yup-d92565dd.js";import"./GenericThumbnailView-4e535459.js";import{F as B}from"./FormInput-8320115a.js";import"./componentStyles-00160cc0.js";import"./ScrollableList-cd5816a8.js";import"./TextArea-ce7716c9.js";import{D as P,a as R}from"./DialogContent-4facb916.js";import{D as T}from"./DialogTitle-3aa960f8.js";import{D as U}from"./DialogContentText-54d95680.js";import{D as $}from"./DialogActions-bd200b72.js";const M=({modal:n,closeModal:o,mastersName:d,edit_Id:a,mastersValue:G})=>{const s=j(),{category:{selectedData:t,pageParams:l},system:{userAccessList:H}}=f(r=>({system:v(r),category:C(r)})),x=E().shape({name:k().required("Please enter your category name").trim()});F.useEffect(()=>{n?i({name:(t==null?void 0:t.name)||""}):i()},[n,t]);const{control:y,handleSubmit:h,reset:i}=L({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(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:[a==null||a==0?"Add ":"Update ",d,e.jsx(S,{onClick:o,children:e.jsx(D,{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"}),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};
