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-60a3c753.js";import{c as F,b as C}from"./index.esm-62d6b2f7.js";import{o as w}from"./yup-92678dde.js";import{u as P}from"./index.esm-c494934a.js";import"./componentStyles-7753bbb9.js";import{F as U}from"./FormInput-74e2c4d2.js";/* empty css                   */import"./ScrollableList-1962b023.js";import{D as $,a as k}from"./DialogContent-89e21f2e.js";import{D as B}from"./DialogTitle-fe69da5c.js";import{D as L}from"./DialogContentText-6688bd59.js";import{D as N}from"./DialogActions-e754942c.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};
