import{d as j,a as f,b as g,qw as v,r as C,j as e,I as S,aM as A,U as l,qx as D,qy as F,qz as q,qA as w}from"./index-c3f592b2.js";import{c as k,b as E,u as U}from"./index.esm-70dd1c06.js";import{o as B}from"./yup-abb4a026.js";import"./GenericThumbnailView-9f1d2f81.js";import{F as L}from"./FormInput-adbf55b1.js";import"./componentStyles-b8fcedb5.js";import"./ScrollableList-ecbfc0f3.js";import"./TextArea-674a9ec6.js";import{D as P,a as T}from"./DialogContent-b7fc1c43.js";import{D as V}from"./DialogTitle-5d3e2030.js";import{D as $}from"./DialogContentText-c3e782dc.js";import{D as z}from"./DialogActions-6e00f4f1.js";const _=({modal:n,closeModal:o,mastersName:u,edit_Id:r,mastersValue:N})=>{const s=j(),{country:{selectedData:t,pageParams:p},system:{userAccessList:R}}=f(a=>({system:g(a),country:v(a)})),x=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:d,handleSubmit:y,reset:i}=U({resolver:B(x),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(D(m)),o(),s(F({})),i()}else{const m={obj:{id:r,name:a.name},pageParams:p,clearDataFn:()=>{},navigate:b=>{}};s(q(m)),o(),s(w(""))}};return e.jsx(e.Fragment,{children:e.jsxs(P,{open:n,onClose:(a,c)=>{c!=="backdropClick"&&o()},"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(V,{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(A,{color:"white"})})]}),e.jsx(T,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx($,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:y(h),children:[e.jsx(L,{name:"name",label:"Name",type:"text",required:!0,placeholder:"Enter Country here...",control:d}),e.jsxs(z,{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};
