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-4dfc510b.js";import{c as k,b as E,u as T}from"./index.esm-0a454763.js";import{o as U}from"./yup-80def618.js";import"./GenericThumbnailView-6256cad7.js";import{F as q}from"./FormInput-f887e69c.js";import"./componentStyles-df94248d.js";import"./ScrollableList-bef4a518.js";import"./TextArea-a0cc14f3.js";import{D as B,a as L}from"./DialogContent-3bf4ff27.js";import{D as P}from"./DialogTitle-248b1818.js";import{D as V}from"./DialogContentText-a6ab23a2.js";import{D as $}from"./DialogActions-49286e71.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};
