import{d as j,a as f,b as g,o0 as v,r as C,j as e,I as S,ax as D,z as l,o1 as F,o2 as A,o3 as w,o4 as k}from"./index-d895656a.js";import{c as E,b as q,u as B}from"./index.esm-1087b2f3.js";import{o as L}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as P}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as T,a as U}from"./DialogContent-4ce43512.js";import{D as V}from"./DialogTitle-738ca272.js";import{D as $}from"./DialogContentText-8b9b0e0c.js";import{D as z}from"./DialogActions-7b82f6f6.js";const _=({modal:n,closeModal:a,mastersName:u,edit_Id:r,mastersValue:N})=>{const s=j(),{country:{selectedData:t,pageParams:p},system:{userAccessList:R}}=f(o=>({system:g(o),country:v(o)})),x=E().shape({name:q().required("Please enter your country name").trim()});C.useEffect(()=>{n?i({name:(t==null?void 0:t.name)||""}):i()},[n,t]);const{control:d,handleSubmit:y,reset:i}=B({resolver:L(x),values:{name:t!=null&&t.name?t==null?void 0:t.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 e.jsx(e.Fragment,{children:e.jsxs(T,{open:n,onClose:(o,c)=>{c!=="backdropClick"&&a()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(V,{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,e.jsx(S,{onClick:a,children:e.jsx(D,{color:"white"})})]}),e.jsx(U,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx($,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:y(h),children:[e.jsx(P,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:d}),e.jsxs(z,{sx:{p:2},children:[e.jsx(l,{onClick:a,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==0?e.jsx(l,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(l,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
