var I=Object.defineProperty;var C=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var h=(s,i,a)=>i in s?I(s,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[i]=a,x=(s,i)=>{for(var a in i||(i={}))M.call(i,a)&&h(s,a,i[a]);if(C)for(var a of C(i))R.call(i,a)&&h(s,a,i[a]);return s};import{_ as e,j as r,z as n}from"./main.2.8.1.js";import{u as E,d as o}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as T}from"./SnackMsg.S8DrwLlT.js";import{S as z}from"./Steps.1hz7v9Vj.js";import{I as L,g as O}from"./Integrations.D2bgBas2.js";import W from"./CopperCRMAuthorization.DEogtRQI.js";import{h as A,c as _}from"./CopperCRMCommonFunc.ZVeVjNfY.js";import{C as B}from"./CopperCRMIntegLayout.RKc90CVl.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function ne({formFields:s,setFlow:i,flow:a,allIntegURL:m}){const c=E(),[S,g]=o.useState(!1),[f,y]=o.useState({}),[l,k]=o.useState(1),[N,u]=o.useState({show:!1}),v=[{key:"name",label:e("Name","bit-integrations"),required:!0},{key:"email_domain",label:e("Email","bit-integrations"),required:!1},{key:"details",label:e("Description","bit-integrations"),required:!1},{key:"street",label:e("Street","bit-integrations"),required:!1},{key:"city",label:e("City","bit-integrations"),required:!1},{key:"state",label:e("State","bit-integrations"),required:!1},{key:"postal_code",label:e("Postal Code","bit-integrations"),required:!1},{key:"country",label:e("Country","bit-integrations"),required:!1},{key:"phone_numbers",label:e("Phone","bit-integrations"),required:!1},{key:"websites",label:e("Website","bit-integrations"),required:!1}],j=[{key:"name",label:e("Name","bit-integrations"),required:!0},{key:"title",label:e("Title","bit-integrations"),required:!1},{key:"details",label:e("Description","bit-integrations"),required:!1},{key:"email_domain",label:e("Email","bit-integrations"),required:!1},{key:"phone_numbers",label:e("Phone","bit-integrations"),required:!1},{key:"street",label:e("Street","bit-integrations"),required:!1},{key:"city",label:e("City","bit-integrations"),required:!1},{key:"state",label:e("State","bit-integrations"),required:!1},{key:"postal_code",label:e("Postal Code","bit-integrations"),required:!1},{key:"country",label:e("Country","bit-integrations"),required:!1},{key:"websites",label:e("Website","bit-integrations"),required:!1}],P=[{key:"name",label:e("Opportunity Name","bit-integrations"),required:!0},{key:"close_date",label:e("Close Date","bit-integrations"),required:!1},{key:"details",label:e("Opportunity Details","bit-integrations"),required:!1},{key:"monetary_value",label:e("Value","bit-integrations"),required:!1}],D=[{key:"name",label:e("Task Name","bit-integrations"),required:!0},{key:"due_date",label:e("Due Date","bit-integrations"),required:!1},{key:"reminder_date",label:e("Reminder Date","bit-integrations"),required:!1},{key:"details",label:e("Description","bit-integrations"),required:!1}],[t,d]=o.useState({name:"CopperCRM",type:"CopperCRM",api_key:"",api_email:"",field_map:[{formField:"",coppercrmFormField:""}],actionName:"",companyFields:v,personFields:j,opportunityFields:P,taskFields:D,actions:{}}),w=()=>{g(!0),O(a,i,m,t,c,"","",g).then(p=>{var q;p.success?(n.success((q=p.data)==null?void 0:q.msg),c(m)):n.error(p.data||p)})},F=b=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!_(t)){n.error(e("Please map mandatory fields","bit-integrations"));return}if(t.actionName==="opportunity"){if(!t.selectedCRMPeople){n.error(e("Please select a people","bit-integrations"));return}if(!t.selectedCRMPipelines&&t.actionName==="opportunity"){n.error(e("Please select a Pipeline","bit-integrations"));return}}t.field_map.length>0&&k(b)};return r.jsxs("div",{children:[r.jsx(T,{snack:N,setSnackbar:u}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(z,{step:3,active:l})}),r.jsx(W,{copperCRMConf:t,setCopperCRMConf:d,step:l,setStep:k,loading:f,setLoading:y,setSnackbar:u}),r.jsxs("div",{className:"btcd-stp-page",style:x({},l===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(B,{formFields:s,handleInput:b=>A(b,t,d),copperCRMConf:t,setCopperCRMConf:d,loading:f,setLoading:y,setSnackbar:u}),(t==null?void 0:t.actionName)&&r.jsxs("button",{onClick:()=>F(3),disabled:!_(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[e("Next","bit-integrations"),"  ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.actionName)&&r.jsx(L,{step:l,saveConfig:()=>w(),isLoading:S,dataConf:t,setDataConf:d,formFields:s})]})}export{ne as default};
