import{d as y,a as f,b as g,ok as v,r as S,j as e,I as A,aI as D,R as c,ol as F,om as p,on as C}from"./index-3141de2d.js";import{c as w,b as B,u as N}from"./index.esm-8b0c9a99.js";import{o as E}from"./yup-c2fea6fa.js";import"./GenericThumbnailView-c2621934.js";import{F as P}from"./FormInput-abff9e70.js";import"./componentStyles-24f97919.js";import"./ScrollableList-fa62971d.js";import"./TextArea-ceaff311.js";import{D as k,a as $}from"./DialogContent-17781b67.js";import{D as q}from"./DialogTitle-16416764.js";import{D as L}from"./DialogContentText-c64ca110.js";import{D as R}from"./DialogActions-37bf04e2.js";const M=({modal:n,closeModal:t,mastersName:T,edit_Id:r,mastersValue:U})=>{const s=y(),{bidnature:{selectedData:a,pageParams:l},system:{userAccessList:z}}=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 m={obj:{name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(F(m)),t(),s(p({})),i()}else{const m={obj:{id:r,name:o.name},pageParams:l,clearDataFn:()=>{},navigate:j=>{}};s(C(m)),s(p({})),t(),i()}};return e.jsx(e.Fragment,{children:e.jsxs(k,{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($,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(L,{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(c,{onClick:t,variant:"outlined",color:"secondary",children:"Cancel"}),r==null||r==""?e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Submit"}):e.jsx(c,{variant:"contained",type:"submit",color:"primary",autoFocus:!0,children:"Update"})]})]})})})]})})};export{M as A};
