import{d as j,a as f,b as g,oX as v,r as C,j as e,I as S,aK as D,R as l,oY as F,oZ as A,o_ as w,o$ as k}from"./index-458d5762.js";import{c as E,b as $,u as q}from"./index.esm-b1b14098.js";import{o as B}from"./yup-536c503d.js";import"./GenericThumbnailView-3cd8dbb5.js";import{F as L}from"./FormInput-3d74947b.js";import"./componentStyles-56425874.js";import"./ScrollableList-ba92364a.js";import"./TextArea-233680fc.js";import{D as P,a as R}from"./DialogContent-2b2d5db0.js";import{D as T}from"./DialogTitle-bda4183d.js";import{D as U}from"./DialogContentText-f6501c39.js";import{D as V}from"./DialogActions-38a5ba62.js";const _=({modal:n,closeModal:a,mastersName:u,edit_Id:r,mastersValue:X})=>{const s=j(),{country:{selectedData:t,pageParams:p},system:{userAccessList:K}}=f(o=>({system:g(o),country:v(o)})),d=E().shape({name:$().required("Please enter your country name").trim()});C.useEffect(()=>{n?i({name:(t==null?void 0:t.name)||""}):i()},[n,t]);const{control:x,handleSubmit:y,reset:i}=q({resolver:B(d),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(P,{open:n,onClose:(o,c)=>{c!=="backdropClick"&&a()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(T,{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(R,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(U,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:y(h),children:[e.jsx(L,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:x}),e.jsxs(V,{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};
