import{d as j,a as f,b as g,p6 as v,r as C,j as t,I as D,aK as S,R as p,p7 as F,p8 as A,p9 as w,pa as k}from"./index-aa25c5ff.js";import{c as E,b as q,u as B}from"./index.esm-a7f661dc.js";import{o as L}from"./yup-72cc4918.js";import"./GenericThumbnailView-e0343bac.js";import{F as P}from"./FormInput-dc74a5d8.js";import"./componentStyles-e32842f3.js";import"./ScrollableList-9498bc37.js";import"./TextArea-d1a16eb1.js";import{D as R}from"./Dialog-049271f6.js";import{D as T}from"./DialogTitle-7a3842b8.js";import{D as U}from"./DialogContent-f207f33c.js";import{D as V}from"./DialogContentText-70face94.js";import{D as $}from"./DialogActions-2338d733.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};
