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-d895656a.js";import{c as k,b as E,u as T}from"./index.esm-1087b2f3.js";import{o as U}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as q}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as B,a as L}from"./DialogContent-4ce43512.js";import{D as P}from"./DialogTitle-738ca272.js";import{D as V}from"./DialogContentText-8b9b0e0c.js";import{D as $}from"./DialogActions-7b82f6f6.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};
