| 1 |
var R=Object.defineProperty,V=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var _=(i,o,a)=>o in i?R(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a,S=(i,o)=>{for(var a in o||(o={}))L.call(o,a)&&_(i,a,o[a]);if(A)for(var a of A(o))O.call(o,a)&&_(i,a,o[a]);return i},w=(i,o)=>V(i,D(o));import{u as G,$ as T,j as e,_ as d,G as q,e as B,F as J,g as K,r as f,S as Q,f as W}from"./main-96.js";/* empty css */import{h as b,a as X,b as M,d as Y,c as U,s as E}from"./bf-13-42.js";import{r as Z,a as g,h as $,c as C}from"./bf-685-95.js";import{A as k}from"./bf-224-73.js";import{m as H}from"./bf-781-46.js";import{M as ee}from"./bf-762-63.js";import{S as z}from"./bf-39-66.js";import{A as se}from"./bf-747-75.js";import{u as te}from"./bf-16-67.js";import"./bf-825-45.js";import"./bf-551-68.js";import"./bf-894-52.js";import"./bf-331-47.js";import"./bf-798-54.js";import"./bf-425-69.js";import"./bf-374-48.js";import"./bf-533-49.js";import"./bf-531-50.js";import"./bf-128-51.js";import"./bf-681-53.js";import"./bf-20-55.js";import"./bf-162-70.js";function le({i,formFields:o,field:a,marketingHubConf:s,setMarketingHubConf:c}){var u,h,F,r,l;const p=a.zohoFormField===""||((u=s.default.fields[s.list].required)==null?void 0:u.indexOf(a.zohoFormField))===-1,j=G(T),{isPro:m}=j;return e.jsxs("div",{className:"flx mt-2 mr-1",children:[e.jsxs("div",{className:"flx integ-fld-wrp",children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:a.formField||"",onChange:t=>b(t,i,s,c),children:[e.jsx("option",{value:"",children:d("Select Field")}),e.jsx("optgroup",{label:"Form Fields",children:o.map(t=>t.type!=="file-up"&&e.jsx("option",{value:t.key,children:t.name},`ff-zhcrm-${t.key}`))}),e.jsx("option",{value:"custom",children:d("Custom...")}),e.jsx("optgroup",{label:`General Smart Codes ${m?"":"(PRO)"}`,children:m&&((h=H)==null?void 0:h.map(t=>e.jsx("option",{value:t.name,children:t.label},`ff-rm-${t.name}`)))})]}),a.formField==="custom"&&e.jsx(ee,{onChange:t=>X(t,i,s,c),label:d("Custom Value"),className:"mr-2",type:"text",value:a.customValue,placeholder:d("Custom Value")}),e.jsxs("select",{className:"btcd-paper-inp",name:"zohoFormField",value:a.zohoFormField||"",disabled:!p,onChange:t=>b(t,i,s,c),children:[e.jsx("option",{value:"",children:d("Select Field")}),p?((l=(r=(F=s==null?void 0:s.default)==null?void 0:F.fields)==null?void 0:r[s.list])==null?void 0:l.fields)&&s.default.fields[s.list].fields.map(t=>t!=="Contact Email"&&e.jsx("option",{value:t,children:t},`${t}-1`)):e.jsx("option",{value:"Contact Email",children:d("Contact Email")},"contact_email")]})]}),e.jsx("button",{onClick:()=>M(i,s,c),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),p&&e.jsx("button",{onClick:()=>Y(i,s,c),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx(q,{})})]})}function ae({formID:i,formFields:o,handleInput:a,marketingHubConf:s,setMarketingHubConf:c,isLoading:p,setisLoading:j,setSnackbar:m}){var u,h,F,r,l,t;return e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("b",{className:"wdt-100 d-in-b",children:d("List:")}),e.jsxs("select",{onChange:n=>a(n),name:"list",value:s.list,className:"btcd-paper-inp w-7",children:[e.jsx("option",{value:"",children:d("Select List")}),((u=s==null?void 0:s.default)==null?void 0:u.lists)&&Object.values(s.default.lists).map(n=>e.jsx("option",{value:n.listkey,children:n.listname},n.listkey))]}),e.jsx("button",{onClick:()=>Z(i,s,c,j,m),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${d("Refresh MarketingHub Lists")}'`},type:"button",disabled:p,children:"↻"}),e.jsx("br",{}),e.jsx("br",{}),p&&e.jsx(B,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),s.list&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:()=>g(i,s,c,j,m),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${d("Refresh MarketingHub Contact Fields")}'`},type:"button",disabled:p,children:"↻"})}),e.jsx("div",{className:"btcd-hr mt-1"}),((F=(h=s.default)==null?void 0:h.fields)==null?void 0:F[s.list])&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flx flx-around mt-2 mb-1",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:d("Form Fields")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:d("Zoho Fields")})})]}),s.field_map.map((n,v)=>e.jsx(le,{i:v,field:n,marketingHubConf:s,formFields:o,setMarketingHubConf:c},`marketingHub-m-${v+9}`)),e.jsxs("div",{className:"txt-center mt-2",style:{marginRight:85},children:[e.jsx("button",{onClick:()=>M(s.field_map.length,s,c),className:"icn-btn sh-sm",type:"button",children:"+"}),e.jsx(k,{fieldMap:s.field_map,formFields:o,integrationFields:((t=(l=(r=s.default)==null?void 0:r.fields)==null?void 0:l[s.list])==null?void 0:t.fields)||[],integKey:"zohoFormField",onMapped:n=>c(v=>w(S({},v),{field_map:n}))})]})]})]})]})}function $e({mode:i="new",formFields:o,integrations:a,setIntegration:s,allIntegURL:c}){const p=J(),{id:j,formID:m}=K(),[u,h]=f.useState(!1),[F,r]=f.useState({show:!1}),[l,t]=f.useState(()=>i==="edit"?S({},a[j]):{name:"Zoho Marketing Hub API",type:"Zoho Marketing Hub",clientId:"",clientSecret:"",list:"",field_map:[{formField:"",zohoFormField:""}]}),n=x=>{const N=JSON.parse(x.integration_details);t(P=>W(P,y=>{y.parentAppId=x.id,y.clientId=N.clientId,y.clientSecret=N.clientSecret,y.tokenDetails=N.tokenDetails,y.dataCenter=N.dataCenter,y.ownerEmail=N.ownerEmail}))};f.useEffect(()=>{l!=null&&l.parentAppId&&Z(m,l,t,h,r)},[l.parentAppId]),f.useEffect(()=>{window.opener&&U("zohoMarketingHub")},[]);const v=()=>{if(!C(l)){r({show:!0,msg:d("Please map mandatory fields")});return}i==="edit"?E(a,s,c,l,p,j,1):E(a,s,c,l,p)},I=i==="edit"||!!l.parentAppId;return te({conf:l,onSeed:x=>t(S({},x)),save:v,saveDisabled:l.list===""||l.table===""||l.field_map.length<1,ready:I}),e.jsxs("div",{children:[e.jsx(Q,{snack:F,setSnackbar:r}),e.jsx(z,{title:d("Name this integration"),children:e.jsx("input",{className:"btcd-paper-inp w-10",onChange:x=>$(x,m,l,t),name:"name",value:l.name,type:"text",placeholder:d("Integration Name...")})}),e.jsx(se,{type:"Zoho Marketing Hub",value:l.parentAppId,onSelect:n}),I&&e.jsx(z,{title:d("Field mapping"),subtitle:d("Choose the destination and match form fields to it."),children:e.jsx(ae,{formID:m,formFields:o,handleInput:x=>$(x,m,l,t,h,r),marketingHubConf:l,setMarketingHubConf:t,isLoading:u,setisLoading:h,setSnackbar:r})})]})}export{$e as default}; |