import{d as j,a as f,b as v,oZ as C,r as D,j as e,I as S,aK as F,R as p,o_ as A,o$ as w,p0 as u}from"./index-aa25c5ff.js";import{c as k,b as E,u as $}from"./index.esm-a7f661dc.js";import{o as q}from"./yup-72cc4918.js";import"./GenericThumbnailView-e0343bac.js";import{F as B}from"./FormInput-dc74a5d8.js";import"./componentStyles-e32842f3.js";import"./ScrollableList-9498bc37.js";import"./TextArea-d1a16eb1.js";import{D as L}from"./Dialog-049271f6.js";import{D as P}from"./DialogTitle-7a3842b8.js";import{D as R}from"./DialogContent-f207f33c.js";import{D as T}from"./DialogContentText-70face94.js";import{D as U}from"./DialogActions-2338d733.js";const _=({modal:n,closeModal:o,mastersName:d,edit_Id:t,mastersValue:K})=>{const s=j(),{category:{selectedData:r,pageParams:l},system:{userAccessList:N}}=f(a=>({system:v(a),category:C(a)})),x=k().shape({name:E().required("Please enter your category name").trim()});D.useEffect(()=>{n?i({name:(r==null?void 0:r.name)||""}):i()},[n,r]);const{control:y,handleSubmit:h,reset:i}=$({resolver:q(x),values:{name:r!=null&&r.name?r==null?void 0:r.name:""}}),g=a=>{if(t==null||t==""){const m={obj:{name:a.name},pageParams:l,clearDataFn:()=>{o(),s(u({})),i()},navigate:b=>{}};s(A(m))}else{const m={obj:{id:t,name:a.name},pageParams:l,clearDataFn:()=>{o(),i(),s(u({}))},navigate:b=>{}};s(w(m))}};return e.jsx(e.Fragment,{children:e.jsxs(L,{open:n,onClose:(a,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:[t==null||t==0?"Add ":"Update ",d,e.jsx(S,{onClick:o,children:e.jsx(F,{color:"white"})})]}),e.jsx(R,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(T,{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(U,{sx:{p:2},children:[e.jsx(p,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),t==null||t==""?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{_ as A};
