import{d as j,a as f,b as v,oO as C,r as S,j as e,I as D,aK as F,R as p,oP as A,oQ as w,oR as u}from"./index-458d5762.js";import{c as k,b as E,u as P}from"./index.esm-b1b14098.js";import{o as R}from"./yup-536c503d.js";import"./GenericThumbnailView-3cd8dbb5.js";import{F as q}from"./FormInput-3d74947b.js";import"./componentStyles-56425874.js";import"./ScrollableList-ba92364a.js";import"./TextArea-233680fc.js";import{D as B,a as L}from"./DialogContent-2b2d5db0.js";import{D as T}from"./DialogTitle-bda4183d.js";import{D as U}from"./DialogContentText-f6501c39.js";import{D as $}from"./DialogActions-38a5ba62.js";const M=({modal:n,closeModal:o,mastersName:d,edit_Id:a,mastersValue:K})=>{const s=j(),{category:{selectedData:t,pageParams:l},system:{userAccessList:N}}=f(r=>({system:v(r),category:C(r)})),x=k().shape({name:E().required("Please enter your category name").trim()});S.useEffect(()=>{n?i({name:(t==null?void 0:t.name)||""}):i()},[n,t]);const{control:y,handleSubmit:h,reset:i}=P({resolver:R(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(B,{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(D,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(L,{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(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};
