import{b as j,a as f,h as g,iU as S,r as v,j as e,I as E,ec as q,K as m,iV as A,iW as D,iX as p}from"./index-def636a4.js";import{c as F,b as C}from"./index.esm-eec4f448.js";import{o as w}from"./yup-c8535458.js";import{u as P}from"./index.esm-7d9d1491.js";import"./componentStyles-41382c67.js";import{F as U}from"./FormInput-8d872744.js";/* empty css                   */import"./ScrollableList-a550bc32.js";import{D as $,a as k}from"./DialogContent-0cb684b3.js";import{D as B}from"./DialogTitle-e2e75924.js";import{D as L}from"./DialogContentText-b2259947.js";import{D as N}from"./DialogActions-c4045764.js";const M=({modal:n,closeModal:t,mastersName:T,edit_Id:a,mastersValue:V})=>{const s=j(),{sourceEnquiry:{selectedData:r,pageParams:l},system:{userAccessList:X}}=f(o=>({system:g(o),sourceEnquiry:S(o)}));v.useEffect(()=>{n?i({name:(r==null?void 0:r.name)||""}):i()},[n,r]);const u=F().shape({name:C().required("Please enter source portal name").trim().matches(/^[a-zA-Z0-9 ]*$/,"source portal name should not contain special characters")}),{control:h,handleSubmit:d,reset:i}=P({resolver:w(u),values:{name:r!=null&&r.name?r==null?void 0:r.name:""}}),x=o=>{if(a==null||a==""){const c={obj:{name:o.name},pageParams:l,clearDataFn:()=>{t(),s(p({})),i()},navigate:b=>{}};s(A(c))}else{const c={obj:{id:a,name:o.name},pageParams:l,clearDataFn:()=>{s(p({})),t(),i()},navigate:b=>{}};s(D(c))}};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(B,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:[a==null||a==0?"Add ":"Update ","Source Of Enquiry",e.jsx(E,{onClick:t,children:e.jsx(q,{color:"white"})})]}),e.jsx(k,{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:d(x),children:[e.jsx(U,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Source Portal here...",control:h}),e.jsxs(N,{sx:{p:2},children:[e.jsx(m,{onClick:t,variant:"outlined",color:"secondary",children:"Cancel"}),a==null||a==""?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};
