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-6f149d0c.js";import{c as k,b as E,u as $}from"./index.esm-88773116.js";import{o as q}from"./yup-7ebcc99d.js";import"./GenericThumbnailView-01fef5a2.js";import{F as B}from"./FormInput-d3efc191.js";import"./componentStyles-d6393a0a.js";import"./ScrollableList-e382be10.js";import"./TextArea-eb0beb3a.js";import{D as L}from"./Dialog-4a8f5dd6.js";import{D as P}from"./DialogTitle-0edc620d.js";import{D as R}from"./DialogContent-398aea0b.js";import{D as T}from"./DialogContentText-12f15d60.js";import{D as U}from"./DialogActions-d3c730f9.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};
