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-60a3c753.js";import{c as $,b as k}from"./index.esm-62d6b2f7.js";import{o as q}from"./yup-92678dde.js";import{u as B}from"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import{F as L}from"./FormInput-74e2c4d2.js";/* empty css                   */import"./ScrollableList-1962b023.js";import{D as P,a as T}from"./DialogContent-89e21f2e.js";import{D as U}from"./DialogTitle-fe69da5c.js";import{D as V}from"./DialogContentText-6688bd59.js";import{D as z}from"./DialogActions-e754942c.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};
