import{b,a as f,h as g,j2 as v,r as C,j as t,I as S,ec as A,K as m,j3 as D,j4 as F,j5 as w,j6 as E}from"./index-76d4793e.js";import{c as $,b as k}from"./index.esm-ad8a7c9f.js";import{o as q}from"./yup-688ec4f6.js";import{u as B}from"./index.esm-3adfd9f7.js";import"./componentStyles-0803b39e.js";import{F as L}from"./FormInput-8f40ded1.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import{D as P,a as T}from"./DialogContent-7bd8dd8f.js";import{D as U}from"./DialogTitle-71dd5b3a.js";import{D as V}from"./DialogContentText-7642f81f.js";import{D as z}from"./DialogActions-5a5e1db9.js";const _=({modal:n,closeModal:a,mastersName:p,edit_Id:r,mastersValue:K})=>{const s=b(),{country:{selectedData:e,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:(e==null?void 0:e.name)||""}):i()},[n,e]);const{control:h,handleSubmit:x,reset:i}=B({resolver:q(u),values:{name:e!=null&&e.name?e==null?void 0:e.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 t.jsx(t.Fragment,{children:t.jsxs(P,{open:n,onClose:a,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[t.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,t.jsx(S,{onClick:a,children:t.jsx(A,{color:"white"})})]}),t.jsx(T,{sx:{px:"24px",pt:"12px !important",pb:0},children:t.jsx(V,{id:"alert-dialog-description",sx:{width:500},children:t.jsxs("form",{style:{width:"100%"},onSubmit:x(y),children:[t.jsx(L,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:h}),t.jsxs(z,{sx:{p:2},children:[t.jsx(m,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==0?t.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):t.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
