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-858224db.js";import{c as E,b as q,u as B}from"./index.esm-241dec99.js";import{o as L}from"./yup-9213c3af.js";import"./GenericThumbnailView-2d7b7363.js";import{F as P}from"./FormInput-8eacbbd9.js";import"./componentStyles-107bd37e.js";import"./ScrollableList-bf78e54b.js";import"./TextArea-78cda1eb.js";import{D as R,a as T}from"./DialogContent-e06a39bc.js";import{D as U}from"./DialogTitle-6e616d34.js";import{D as V}from"./DialogContentText-a2775ca2.js";import{D as $}from"./DialogActions-825c19e9.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};
