import{d as y,a as f,b as g,o9 as v,r as S,j as e,I as A,ax as D,z as m,oa as F,ob as p,oc as C}from"./index-d895656a.js";import{c as w,b as B,u as N}from"./index.esm-1087b2f3.js";import{o as E}from"./yup-9573aa79.js";import"./GenericThumbnailView-532ea2d7.js";import{F as P}from"./FormInput-9b5da280.js";import"./componentStyles-866300fe.js";import"./ScrollableList-e2b22048.js";import"./TextArea-fb0d0821.js";import{D as $,a as k}from"./DialogContent-4ce43512.js";import{D as q}from"./DialogTitle-738ca272.js";import{D as z}from"./DialogContentText-8b9b0e0c.js";import{D as L}from"./DialogActions-7b82f6f6.js";const M=({modal:n,closeModal:t,mastersName:T,edit_Id:r,mastersValue:U})=>{const s=y(),{bidnature:{selectedData:a,pageParams:l},system:{userAccessList:R}}=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:x,reset:i}=N({resolver:E(u),values:{name:a!=null&&a.name?a==null?void 0:a.name:""}}),h=o=>{if(r==null||r==""){const c={obj:{name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(F(c)),t(),s(p({})),i()}else{const c={obj:{id:r,name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(C(c)),s(p({})),t(),i()}};return e.jsx(e.Fragment,{children:e.jsxs($,{open:n,onClose:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(q,{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(k,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(z,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:x(h),children:[e.jsx(P,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Source Portal here...",control:d}),e.jsxs(L,{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};
