var z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var v=(s,i,a)=>i in s?z(s,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[i]=a,N=(s,i)=>{for(var a in i||(i={}))F.call(i,a)&&v(s,a,i[a]);if(x)for(var a of x(i))E.call(i,a)&&v(s,a,i[a]);return s};import{_ as t,j as n,z as m}from"./main.2.8.1.js";import{u as A,d as r}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as L}from"./SnackMsg.S8DrwLlT.js";import{S as M}from"./Steps.1hz7v9Vj.js";import{I as T,g as D}from"./Integrations.D2bgBas2.js";import B from"./ClinchPadAuthorization.YxXKE6wV.js";import{h as R,c as S}from"./ClinchPadCommonFunc.DI-lX3n6.js";import{C as W}from"./ClinchPadIntegLayout.Cw5CwkaY.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";function ae({formFields:s,setFlow:i,flow:a,allIntegURL:b}){const u=A(),[j,g]=r.useState(!1),[f,h]=r.useState({}),[o,k]=r.useState(1),[q,p]=r.useState({show:!1}),C=[{key:"name",label:t("Name","bit-integrations"),required:!0},{key:"phone",label:t("Phone","bit-integrations"),required:!1},{key:"email",label:t("Email","bit-integrations"),required:!1},{key:"website",label:t("Website","bit-integrations"),required:!1},{key:"address",label:t("Address","bit-integrations"),required:!1}],P=[{key:"name",label:t("Name","bit-integrations"),required:!0},{key:"designation",label:t("Designation","bit-integrations"),required:!1},{key:"phone",label:t("Phone","bit-integrations"),required:!1},{key:"email",label:t("Email","bit-integrations"),required:!1},{key:"address",label:t("Address","bit-integrations"),required:!1}],I=[{key:"name",label:t("Name","bit-integrations"),required:!0},{key:"size",label:t("Size","bit-integrations"),required:!1}],[e,l]=r.useState({name:"ClinchPad",type:"ClinchPad",api_key:"",field_map:[{formField:"",clinchPadFormField:""}],actionName:"",organizationFields:C,contactFields:P,leadFields:I,actions:{}}),_=()=>{g(!0),D(a,i,b,e,u,"","",g).then(c=>{var y;c.success?(m.success((y=c.data)==null?void 0:y.msg),u(b)):m.error(c.data||c)})},w=d=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!S(e)){m.error(t("Please map mandatory fields","bit-integrations"));return}if(e.actionName==="lead"&&!e.selectedCRMPipeline){m.error(t("Please select a pipeline","bit-integrations"));return}e.field_map.length>0&&k(d)};return n.jsxs("div",{children:[n.jsx(L,{snack:q,setSnackbar:p}),n.jsx("div",{className:"txt-center mt-2",children:n.jsx(M,{step:3,active:o})}),n.jsx(B,{clinchPadConf:e,setClinchPadConf:l,step:o,setStep:k,loading:f,setLoading:h,setSnackbar:p}),n.jsxs("div",{className:"btcd-stp-page",style:N({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[n.jsx(W,{formFields:s,handleInput:d=>R(d,e,l),clinchPadConf:e,setClinchPadConf:l,loading:f,setLoading:h,setSnackbar:p}),(e==null?void 0:e.actionName)&&n.jsxs("button",{onClick:()=>w(3),disabled:!S(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[t("Next","bit-integrations"),"  ",n.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&n.jsx(T,{step:o,saveConfig:()=>_(),isLoading:j,dataConf:e,setDataConf:l,formFields:s})]})}export{ae as default};
