import{b as j,a as f,g,vV as v,r as S,j as e,I as E,ef as q,J as m,vW as A,vX as D,vY as p}from"./index-d2b25495.js";import{c as F,b as C}from"./index.esm-3043d6d4.js";import{o as w}from"./yup-267e586f.js";import{u as P}from"./index.esm-ce3c2c20.js";import"./componentStyles-0e851d91.js";import{F as $}from"./FormInput-d202e905.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import{D as k,a as B}from"./DialogContent-cded694d.js";import{D as L}from"./DialogTitle-a145b392.js";import{D as N}from"./DialogContentText-43575e44.js";import{D as T}from"./DialogActions-7c802cc8.js";const M=({modal:i,closeModal:t,mastersName:U,edit_Id:a,mastersValue:V})=>{const s=j(),{sourceEnquiry:{selectedData:r,pageParams:l},system:{userAccessList:X}}=f(o=>({system:g(o),sourceEnquiry:v(o)}));S.useEffect(()=>{i?n({name:(r==null?void 0:r.name)||""}):n()},[i,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:d,handleSubmit:h,reset:n}=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({})),n()},navigate:b=>{}};s(A(c))}else{const c={obj:{id:a,name:o.name},pageParams:l,clearDataFn:()=>{s(p({})),t(),n()},navigate:b=>{}};s(D(c))}};return e.jsx(e.Fragment,{children:e.jsxs(k,{open:i,onClose:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[e.jsxs(L,{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(B,{sx:{px:"24px",pt:"12px !important",pb:0},children:e.jsx(N,{id:"alert-dialog-description",sx:{width:500},children:e.jsxs("form",{style:{width:"100%"},onSubmit:h(x),children:[e.jsx($,{name:"name",label:"Name",required:!0,type:"text",placeholder:"Enter Source Portal here...",control:d}),e.jsxs(T,{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};
