| 1 |
import{F as D,g as M,r as n,f as A,j as t,M as b,S as C}from"./main-294.js";import"./bf-176-80.js";import{S as z}from"./bf-619-257.js";import{C as P}from"./bf-523-87.js";import{ac as T,s as L,a7 as _}from"./bf-813-81.js";import{I as $}from"./bf-906-183.js";import{N as J}from"./bf-744-108.js";import{Z as j}from"./bf-825-96.js";import{Z as O}from"./bf-218-191.js";import"./bf-582-82.js";import"./bf-158-107.js";function Y({formFields:I,setIntegration:y,integrations:k,allIntegURL:p}){const f=D(),{formID:x}=M(),[S,g]=n.useState(!1),[N,h]=n.useState(!1),[a,l]=n.useState(1),[E,m]=n.useState({show:!1}),[e,d]=n.useState({name:"Zoho Mail API",type:"Zoho Mail",clientId:"",clientSecret:"",actions:{},to:"",cc:"",bcc:"",subject:"",body:""}),u=T([e.type]),w=()=>{setTimeout(()=>{f(`${p}/new/${e.type}`)},1e3),h(!1)},Z=(i,r)=>{if(i.integration_type===e.type){const o=JSON.parse(i.integration_details);d(s=>A(s,c=>{c.parentAppId=i.id,c.clientId=o.clientId,c.clientSecret=o.clientSecret,c.tokenDetails=o.tokenDetails,c.dataCenter=o.dataCenter,c.ownerEmail=o.ownerEmail})),l(2)}};n.useEffect(()=>{d(i=>A(i,r=>{const o=u.find(s=>s.id===e.parentAppId);if(o){const s=JSON.parse(o.integration_details);r.clientId=s.clientId,r.clientSecret=s.clientSecret,r.tokenDetails=s.tokenDetails,r.dataCenter=s.dataCenter,r.ownerEmail=s.ownerEmail}}))},[e.parentAppId]),n.useEffect(()=>{window.opener&&L("zohoMail")},[]);const v=i=>{l(i)};return t.jsxs("div",{children:[t.jsx(b,{title:"Authorize New Zoho Mail App",show:N,setModal:()=>h(!1),children:t.jsx(j,{formID:x,mailConf:e,setMailConf:d,step:a,setStep:l,isLoading:S,setisLoading:g,setSnackbar:m,authorizedAction:w})}),t.jsx(C,{snack:E,setSnackbar:m}),t.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:t.jsx(z,{step:3,active:a})}),u.length>0&&a===1&&t.jsx(P,{allIntegURL:p,specificTypes:[e.type],onClickAction:Z,allowAddNew:!0,addNewAction:()=>h(!0)}),a===1&&u.length===0&&t.jsx(j,{formID:x,mailConf:e,setMailConf:d,step:a,setStep:l,isLoading:S,setisLoading:g,setSnackbar:m,authorizedAction:w}),t.jsxs("div",{className:"btcd-stp-page",style:{width:a===2&&900,height:a===2&&"100%"},children:[t.jsx(O,{formFields:I,mailConf:e,setMailConf:d}),t.jsx(J,{nextPageHandler:()=>v(3)})]}),t.jsx($,{step:a,saveConfig:()=>_(k,y,p,e,f)})]})}export{Y as default}; |