import{d as y,a as f,b as g,pW as v,r as S,j as e,I as A,aL as D,R as m,pX as F,pY as l,pZ as C}from"./index-952e178b.js";import{c as w,b as B,u as N}from"./index.esm-6feddb16.js";import{o as E}from"./yup-d92565dd.js";import"./GenericThumbnailView-4e535459.js";import{F as P}from"./FormInput-8320115a.js";import"./componentStyles-00160cc0.js";import"./ScrollableList-cd5816a8.js";import"./TextArea-ce7716c9.js";import{D as L,a as $}from"./DialogContent-4facb916.js";import{D as k}from"./DialogTitle-3aa960f8.js";import{D as q}from"./DialogContentText-54d95680.js";import{D as R}from"./DialogActions-bd200b72.js";const M=({modal:n,closeModal:t,mastersName:T,edit_Id:r,mastersValue:U})=>{const s=y(),{bidnature:{selectedData:a,pageParams:p},system:{userAccessList:X}}=f(o=>({system:g(o),bidnature:v(o)}));S.useEffect(()=>{n?i({name:(a==null?void 0:a.name)||""}):i()},[n,a]);const u=w().shape({name:B().required("Please enter source portal name").trim().matches(/^[a-zA-Z0-9 ]*$/,"source portal name should not contain special characters")}),{control:d,handleSubmit:h,reset:i}=N({resolver:E(u),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),x=o=>{if(r==null||r==""){const c={obj:{name:o.name},pageParams:p,clearDataFn:()=>{},navigate:j=>{}};s(F(c)),t(),s(l({})),i()}else{const c={obj:{id:r,name:o.name},pageParams:p,clearDataFn:()=>{},navigate:j=>{}};s(C(c)),s(l({})),t(),i()}};return e.jsx(e.Fragment,{children:e.jsxs(L,{open:n,onClose:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(k,{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 ","Source Portal",e.jsx(A,{onClick:t,children:e.jsx(D,{color:"white"})})]}),e.jsx($,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(q,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(x),children:[e.jsx(P,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Source Portal here...",control:d}),e.jsxs(R,{sx:{p:2},children:[e.jsx(m,{onClick:t,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==""?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{M as A};
