import{d as j,a as f,b as g,p5 as v,r as C,j as t,I as D,aK as S,R as p,p6 as F,p7 as A,p8 as w,p9 as k}from"./index-e6164346.js";import{c as E,b as q,u as B}from"./index.esm-0a041314.js";import{o as L}from"./yup-5fd5d57b.js";import"./GenericThumbnailView-80c6fd98.js";import{F as P}from"./FormInput-859198ec.js";import"./componentStyles-00385170.js";import"./ScrollableList-5a17e8f4.js";import"./TextArea-f5c200de.js";import{D as R}from"./Dialog-2e8a8e2e.js";import{D as T}from"./DialogTitle-8757f50f.js";import{D as U}from"./DialogContent-f10d6731.js";import{D as V}from"./DialogContentText-027be15d.js";import{D as $}from"./DialogActions-31bec80e.js";const tt=({modal:n,closeModal:o,mastersName:u,edit_Id:r,mastersValue:K})=>{const s=j(),{country:{selectedData:e,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:(e==null?void 0:e.name)||""}):i()},[n,e]);const{control:x,handleSubmit:y,reset:i}=B({resolver:L(d),values:{name:e!=null&&e.name?e==null?void 0:e.name:""}}),h=a=>{if(r==null||r==0){const m={obj:{name:a.name},pageParams:l,clearDataFn:()=>{},navigate:b=>{}};s(F(m)),o(),s(A({})),i()}else{const m={obj:{id:r,name:a.name},pageParams:l,clearDataFn:()=>{},navigate:b=>{}};s(w(m)),o(),s(k(""))}};return t.jsx(t.Fragment,{children:t.jsxs(R,{open:n,onClose:(a,c)=>{c!=="backdropClick"&&o()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[t.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,t.jsx(D,{onClick:o,children:t.jsx(S,{color:"white"})})]}),t.jsx(U,{sx:{px:"24px",pt:"12px !important",pb:0},children:t.jsx(V,{id:"alert-dialog-description",sx:{width:500},children:t.jsxs("form",{style:{width:"100%"},onSubmit:y(h),children:[t.jsx(P,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:x}),t.jsxs($,{sx:{p:2},children:[t.jsx(p,{onClick:o,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==0?t.jsx(p,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):t.jsx(p,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{tt as A};
