import{d as j,a as f,b as v,nT as C,r as S,j as e,I as D,ax as F,z as p,nU as A,nV as w,nW as u}from"./index-c5c88b67.js";import{c as k,b as E,u as T}from"./index.esm-81620445.js";import{o as U}from"./yup-41605283.js";import"./GenericThumbnailView-43782201.js";import{F as q}from"./FormInput-86f14880.js";import"./componentStyles-a5e5a830.js";import"./ScrollableList-21ab2b9c.js";import"./TextArea-aad9dffe.js";import{D as B,a as L}from"./DialogContent-1350b249.js";import{D as P}from"./DialogTitle-da236dcc.js";import{D as V}from"./DialogContentText-659ecbc3.js";import{D as $}from"./DialogActions-1232a7fa.js";const M=({modal:i,closeModal:o,mastersName:x,edit_Id:a,mastersValue:z})=>{const s=j(),{category:{selectedData:t,pageParams:l},system:{userAccessList:N}}=f(r=>({system:v(r),category:C(r)})),d=k().shape({name:E().required("Please enter your category name").trim()});S.useEffect(()=>{i?n({name:(t==null?void 0:t.name)||""}):n()},[i,t]);const{control:y,handleSubmit:h,reset:n}=T({resolver:U(d),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({})),n()},navigate:b=>{}};s(A(m))}else{const m={obj:{id:a,name:r.name},pageParams:l,clearDataFn:()=>{o(),n(),s(u({}))},navigate:b=>{}};s(w(m))}};return e.jsx(e.Fragment,{children:e.jsxs(B,{open:i,onClose:(r,c)=>{c!=="backdropClick"&&o()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(P,{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 ",x,e.jsx(D,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(L,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(V,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(g),children:[e.jsx(q,{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};
