import{d as j,a as f,b as g,pN as v,r as C,j as e,I as S,aL as D,R as m,pO as F,pP as A,pQ as w,pR as k}from"./index-952e178b.js";import{c as E,b as L,u as P}from"./index.esm-6feddb16.js";import{o as R}from"./yup-d92565dd.js";import"./GenericThumbnailView-4e535459.js";import{F as q}from"./FormInput-8320115a.js";import"./componentStyles-00160cc0.js";import"./ScrollableList-cd5816a8.js";import"./TextArea-ce7716c9.js";import{D as B,a as N}from"./DialogContent-4facb916.js";import{D as T}from"./DialogTitle-3aa960f8.js";import{D as U}from"./DialogContentText-54d95680.js";import{D as V}from"./DialogActions-bd200b72.js";const _=({modal:n,closeModal:o,mastersName:u,edit_Id:r,mastersValue:$})=>{const s=j(),{country:{selectedData:t,pageParams:l},system:{userAccessList:O}}=f(a=>({system:g(a),country:v(a)})),d=E().shape({name:L().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}=P({resolver:R(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(B,{open:n,onClose:(a,c)=>{c!=="backdropClick"&&o()},"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:o,children:e.jsx(D,{color:"white"})})]}),e.jsx(N,{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(q,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:x}),e.jsxs(V,{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};
