| 1 |
var E=Object.defineProperty;var N=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var g=(l,s,c)=>s in l?E(l,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):l[s]=c,h=(l,s)=>{for(var c in s||(s={}))I.call(s,c)&&g(l,c,s[c]);if(N)for(var c of N(s))V.call(s,c)&&g(l,c,s[c]);return l};import{r as f,j as e,T as Z,_ as a,d as B,bw as $,u as D,bd as F,f as C,F as O,g as _,S as H}from"./main-762.js";/* empty css */import{c as P,s as A}from"./bf-767-42.js";import{h as z}from"./bf-44-87.js";import{u as w}from"./bf-871-60.js";import{u as G}from"./bf-435-62.js";import{d as J}from"./bf-685-46.js";import{S}from"./bf-432-66.js";import{A as R}from"./bf-462-75.js";import{u as U}from"./bf-689-67.js";import"./bf-383-45.js";import"./bf-848-68.js";import"./bf-241-52.js";import"./bf-145-47.js";import"./bf-213-54.js";import"./bf-249-69.js";import"./bf-281-48.js";import"./bf-284-49.js";import"./bf-466-50.js";import"./bf-604-51.js";import"./bf-441-53.js";import"./bf-897-55.js";import"./bf-959-70.js";function W({formFields:l,mailConf:s,setMailConf:c}){const[j,r]=f.useState({show:!1}),p=(n,v)=>{const u=h({},s);n!==""?u.actions.attachments=n:delete u.actions.attachments,c(h({},u))};return e.jsxs("div",{className:"pos-rel",children:[e.jsx("div",{className:"d-flx flx-wrp",children:e.jsx(Z,{onChange:()=>r({show:"attachments"}),checked:"attachments"in s.actions,className:"wdt-200 mt-4 mr-2",value:"Attachment",title:a("Attachments"),subTitle:a("Add attachments from BitForm to mail pushed to Zoho Mail.")})}),e.jsxs(B,{className:"custom-conf-mdl",mainMdlCls:"o-v",btnClass:"blue",btnTxt:"Ok",show:j.show==="attachments",close:()=>r({show:!1}),action:()=>r({show:!1}),title:a("Select Attachment"),children:[e.jsx("div",{className:"btcd-hr mt-2"}),e.jsx("div",{className:"mt-2",children:a("Select file upload fields")}),e.jsx(w,{defaultValue:s.actions.attachments,className:"mt-2 w-9",onChange:n=>p(n),options:l.filter(n=>$.includes(n.type)).map(n=>({label:n.name,value:n.key}))})]})]})}function q({formFields:l,mailConf:s,setMailConf:c}){const j=D(F),{userMail:r}=G(),p=()=>{const t=[];r&&Array.isArray(r)&&t.push(...r);const o=[];return l.map(i=>{i.type==="email"&&o.push({label:i.name,value:`\${${i.key}}`})}),t.push({title:"Form Fields",type:"group",childs:o}),t},n=(t,o)=>{c(i=>{const x=h({},i);return x[o]=t,x})},v=t=>{c(o=>C(o,i=>{i.body=t}))},u=t=>{const o=h({},s);o.subject+=t.target.value,c(h({},o)),t.target.value=""};return e.jsxs("div",{style:{width:875},children:[e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("Type:")}),e.jsxs("select",{onChange:t=>n(t.target.value,"mailType"),className:"btcd-paper-inp",style:{width:150},value:s.mailType,children:[e.jsx("option",{value:"",children:a("Select type")}),e.jsx("option",{value:"send",children:a("Send Email")}),e.jsx("option",{value:"draft",children:a("Save as Draft")})]})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:"To:"}),e.jsx(w,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:s.to,placeholder:a("Add Email Receiver"),onChange:t=>n(t,"to"),options:p(),customValue:!0})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("CC:")}),e.jsx(w,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:s.cc,placeholder:a("Add Email CC"),onChange:t=>n(t,"cc"),options:p(),customValue:!0})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("BCC:")}),e.jsx(w,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:s.bcc,placeholder:a("Add Email BCC"),onChange:t=>n(t,"bcc"),options:p(),customValue:!0})]}),e.jsxs("div",{className:"mt-2 flx",children:[e.jsx("b",{style:{width:100},children:a("Subject:")}),e.jsx("input",{type:"text",onChange:t=>n(t.target.value,"subject"),className:"btcd-paper-inp w-7",placeholder:a("Email Subject Here"),value:s.subject||""}),e.jsxs("select",{onChange:u,className:"btcd-paper-inp ml-2",style:{width:150},children:[e.jsx("option",{value:"",children:a("Add form field")}),l!==null&&l.map(t=>!t.type.match(/^(file-up|recaptcha)$/)&&e.jsx("option",{value:`\${${t.key}}`,children:t.name},t.key))]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"flx flx-between",children:e.jsx("b",{children:a("Body:")})}),e.jsx(J,{id:"body-content",formFields:j,value:s.body||"",onChangeHandler:v})]}),e.jsx("br",{}),e.jsx("br",{}),e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:a("Actions")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsx(W,{mailConf:s,setMailConf:c,formFields:l})]})}function ve({mode:l="new",formFields:s,integrations:c,setIntegration:j,allIntegURL:r}){const p=O(),{id:n}=_(),[v,u]=f.useState({show:!1}),[t,o]=f.useState({show:!1}),[i,x]=f.useState(()=>l==="edit"?h({},c[n]):{name:"Zoho Mail API",type:"Zoho Mail",clientId:"",clientSecret:"",actions:{},to:"",cc:"",bcc:"",subject:"",body:""}),k=d=>{const m=JSON.parse(d.integration_details);x(T=>C(T,b=>{b.parentAppId=d.id,b.clientId=m.clientId,b.clientSecret=m.clientSecret,b.tokenDetails=m.tokenDetails,b.dataCenter=m.dataCenter,b.ownerEmail=m.ownerEmail}))};f.useEffect(()=>{window.opener&&P("zohoMail")},[]);const M=()=>{var d,m;if(l==="edit"){if((d=i.actions)!=null&&d.update&&((m=i.actions)==null?void 0:m.update.criteria)===""&&t.show!=="criteria"){o({show:"criteria"});return}A(c,j,r,i,p,n,1);return}A(c,j,r,i,p)},y=l==="edit"||!!i.parentAppId;return U({conf:i,onSeed:d=>x(h({},d)),save:M,saveDisabled:!1,ready:y}),e.jsxs("div",{children:[e.jsx(H,{snack:v,setSnackbar:u}),e.jsx(S,{title:a("Name this integration"),children:e.jsx("input",{className:"btcd-paper-inp w-10",onChange:d=>z(d,i,x),name:"name",value:i.name,type:"text",placeholder:a("Integration Name...")})}),e.jsx(R,{type:"Zoho Mail",value:i.parentAppId,onSelect:k}),y&&e.jsx(S,{title:a("Field mapping"),subtitle:a("Choose the destination and match form fields to it."),children:e.jsx(q,{formFields:s,mailConf:i,setMailConf:x})})]})}export{ve as default}; |