import{b,a as f,g,j7 as v,r as C,j as t,I as S,ef as A,J as m,j8 as D,j9 as F,ja as w,jb as E}from"./index-d2b25495.js";import{c as $,b as k}from"./index.esm-3043d6d4.js";import{o as q}from"./yup-267e586f.js";import{u as B}from"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import{F as L}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{D as P,a as T}from"./DialogContent-cded694d.js";import{D as U}from"./DialogTitle-a145b392.js";import{D as V}from"./DialogContentText-43575e44.js";import{D as z}from"./DialogActions-7c802cc8.js";const _=({modal:n,closeModal:a,mastersName:p,edit_Id:r,mastersValue:J})=>{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};
