import{d as j,a as f,b as g,ql as v,r as C,j as e,I as S,aL as D,R as l,qm as F,qn as q,qo as A,qp as w}from"./index-e79f7aad.js";import{c as k,b as E,u as L}from"./index.esm-1ca67d65.js";import{o as B}from"./yup-96f14780.js";import"./GenericThumbnailView-8a83a30c.js";import{F as P}from"./FormInput-07daa19d.js";import"./componentStyles-7718fc5e.js";import"./ScrollableList-5929779e.js";import"./TextArea-ec29d1d5.js";import{D as R,a as T}from"./DialogContent-6a297cef.js";import{D as U}from"./DialogTitle-62595023.js";import{D as V}from"./DialogContentText-0c5306f9.js";import{D as $}from"./DialogActions-edd1d02f.js";const _=({modal:n,closeModal:o,mastersName:u,edit_Id:r,mastersValue:N})=>{const s=j(),{country:{selectedData:t,pageParams:p},system:{userAccessList:X}}=f(a=>({system:g(a),country:v(a)})),d=k().shape({name:E().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}=L({resolver:B(d),values:{name:t!=null&&t.name?t==null?void 0:t.name:""}}),h=a=>{if(r==null||r==0){const m={obj:{name:a.name},pageParams:p,clearDataFn:()=>{},navigate:b=>{}};s(F(m)),o(),s(q({})),i()}else{const m={obj:{id:r,name:a.name},pageParams:p,clearDataFn:()=>{},navigate:b=>{}};s(A(m)),o(),s(w(""))}};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(l,{onClick:o,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};
