import{b,a as f,h as g,je as v,r as C,j as e,I as S,ec as A,K as m,jf as D,jg as F,jh as w,ji as E}from"./index-43bf7a1c.js";import{c as $,b as k}from"./index.esm-f9e0a906.js";import{o as q}from"./yup-3b80ed10.js";import{u as B}from"./index.esm-0548c843.js";import"./componentStyles-4624000e.js";import{F as L}from"./FormInput-33b720a4.js";/* empty css                   */import"./ScrollableList-e19132c3.js";import{D as P,a as T}from"./DialogContent-d5902709.js";import{D as U}from"./DialogTitle-20dc6f66.js";import{D as V}from"./DialogContentText-abf03c9f.js";import{D as z}from"./DialogActions-d63c6496.js";const _=({modal:n,closeModal:a,mastersName:p,edit_Id:r,mastersValue:K})=>{const s=b(),{country:{selectedData:t,pageParams:l},system:{userAccessList:N}}=f(o=>({system:g(o),country:v(o)})),u=$().shape({name:k().required("Please enter your country name").trim().matches(/^[a-zA-Z0-9 ]*$/,"country name should not contain special characters")});C.useEffect(()=>{n?i({name:(t==null?void 0:t.name)||""}):i()},[n,t]);const{control:h,handleSubmit:x,reset:i}=B({resolver:q(u),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),y=o=>{if(r==null||r==0){const c={obj:{name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(D(c)),a(),s(F({})),i()}else{const c={obj:{id:r,name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(w(c)),a(),s(E(""))}};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:n,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(U,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[r==null||r==0?"Add ":"Update ",p,e.jsx(S,{onClick:a,children:e.jsx(A,{color:"white"})})]}),e.jsx(T,{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:x(y),children:[e.jsx(L,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:h}),e.jsxs(z,{sx:{p:2},children:[e.jsx(m,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==0?e.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
