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-6f149d0c.js";import{c as E,b as q,u as B}from"./index.esm-88773116.js";import{o as L}from"./yup-7ebcc99d.js";import"./GenericThumbnailView-01fef5a2.js";import{F as P}from"./FormInput-d3efc191.js";import"./componentStyles-d6393a0a.js";import"./ScrollableList-e382be10.js";import"./TextArea-eb0beb3a.js";import{D as R}from"./Dialog-4a8f5dd6.js";import{D as T}from"./DialogTitle-0edc620d.js";import{D as U}from"./DialogContent-398aea0b.js";import{D as V}from"./DialogContentText-12f15d60.js";import{D as $}from"./DialogActions-d3c730f9.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};
