import{d as j,a as f,b as g,p7 as v,r as C,j as e,I as S,aK as D,R as m,p8 as F,p9 as A,pa as w,pb as k}from"./index-5ae5cc5e.js";import{c as E,b as q,u as B}from"./index.esm-bd37e938.js";import{o as L}from"./yup-86a48159.js";import"./GenericThumbnailView-fac7773c.js";import{F as P}from"./FormInput-77541d96.js";import"./componentStyles-7d84c389.js";import"./ScrollableList-2ee889f8.js";import"./TextArea-20f097f8.js";import{D as R,a as T}from"./DialogContent-e2578cbd.js";import{D as U}from"./DialogTitle-4a5aec12.js";import{D as V}from"./DialogContentText-bc10bf8d.js";import{D as $}from"./DialogActions-ad26e3d6.js";const _=({modal:n,closeModal:o,mastersName:u,edit_Id:r,mastersValue:K})=>{const s=j(),{country:{selectedData:t,pageParams:l},system:{userAccessList:N}}=f(a=>({system:g(a),country:v(a)})),d=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:x,handleSubmit:y,reset:i}=B({resolver:L(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),h=a=>{if(r==null||r==0){const p={obj:{name:a.name},pageParams:l,clearDataFn:()=>{},navigate:b=>{}};s(F(p)),o(),s(A({})),i()}else{const p={obj:{id:r,name:a.name},pageParams:l,clearDataFn:()=>{},navigate:b=>{}};s(w(p)),o(),s(k(""))}};return e.jsx(e.Fragment,{children:e.jsxs(R,{open:n,onClose:(a,c)=>{c!=="backdropClick"&&o()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.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,e.jsx(S,{onClick:o,children:e.jsx(D,{color:"white"})})]}),e.jsx(T,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(V,{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:x}),e.jsxs($,{sx:{p:2},children:[e.jsx(m,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==0?e.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(m,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{_ as A};
