import{d as j,a as f,b as v,oY as C,r as D,j as e,I as S,aK as F,R as p,oZ as A,o_ as w,o$ as u}from"./index-e6164346.js";import{c as k,b as E,u as $}from"./index.esm-0a041314.js";import{o as q}from"./yup-5fd5d57b.js";import"./GenericThumbnailView-80c6fd98.js";import{F as B}from"./FormInput-859198ec.js";import"./componentStyles-00385170.js";import"./ScrollableList-5a17e8f4.js";import"./TextArea-f5c200de.js";import{D as L}from"./Dialog-2e8a8e2e.js";import{D as P}from"./DialogTitle-8757f50f.js";import{D as R}from"./DialogContent-f10d6731.js";import{D as T}from"./DialogContentText-027be15d.js";import{D as U}from"./DialogActions-31bec80e.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};
