import{d as j,a as f,b as g,os as v,r as C,j as t,I as S,aI as D,R as l,ot as F,ou as A,ov as w,ow as k}from"./index-0698dbe6.js";import{c as E,b as q,u as B}from"./index.esm-85d015f3.js";import{o as L}from"./yup-7a53beb8.js";import"./GenericThumbnailView-dca658f3.js";import{F as P}from"./FormInput-98c39817.js";import"./componentStyles-91278318.js";import"./ScrollableList-fc87149c.js";import"./TextArea-91c96faf.js";import{D as R,a as T}from"./DialogContent-6dbfd908.js";import{D as U}from"./DialogTitle-a8d1726a.js";import{D as V}from"./DialogContentText-ceb40f80.js";import{D as $}from"./DialogActions-318201e3.js";const _=({modal:n,closeModal:a,mastersName:u,edit_Id:r,mastersValue:N})=>{const s=j(),{country:{selectedData:e,pageParams:p},system:{userAccessList:X}}=f(o=>({system:g(o),country:v(o)})),d=E().shape({name:q().required("Please enter your country name").trim()});C.useEffect(()=>{n?i({name:(e==null?void 0:e.name)||""}):i()},[n,e]);const{control:x,handleSubmit:y,reset:i}=B({resolver:L(d),values:{name:e!=null&&e.name?e==null?void 0:e.name:""}}),h=o=>{if(r==null||r==0){const m={obj:{name:o.name},pageParams:p,clearDataFn:()=>{},navigate:b=>{}};s(F(m)),a(),s(A({})),i()}else{const m={obj:{id:r,name:o.name},pageParams:p,clearDataFn:()=>{},navigate:b=>{}};s(w(m)),a(),s(k(""))}};return t.jsx(t.Fragment,{children:t.jsxs(R,{open:n,onClose:(o,c)=>{c!=="backdropClick"&&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 ",u,t.jsx(S,{onClick:a,children:t.jsx(D,{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:y(h),children:[t.jsx(P,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:x}),t.jsxs($,{sx:{p:2},children:[t.jsx(l,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==0?t.jsx(l,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):t.jsx(l,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
