import{k as F,g as v,j as t,_ as p}from"./main.2.8.1.js";import{u as y,h as k,d}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{B as W}from"./BackIcn._kGL_vVw.js";import{S as N}from"./SnackMsg.S8DrwLlT.js";import{S as L}from"./Steps.1hz7v9Vj.js";import{I as P,g as B}from"./Integrations.D2bgBas2.js";import E from"./WooCommerceAuthorization.DDMPLu08.js";import{W as T,h as D,c as i}from"./WooCommerceIntegLayout.YY7CBApc.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 Z({formFields:c,setFlow:h,flow:x,allIntegURL:M}){const b=y(),{formID:_}=k(),S=F(v),{isPro:j}=S,[l,r]=d.useState(!1),[o,u]=d.useState(1),[I,s]=d.useState({show:!1}),[e,n]=d.useState({name:"WooCommerce Integration",type:"WooCommerce",field_map:[],upload_field_map:[],line_field_map:[{formField:"",wcField:""}],actions:{}}),C=()=>{let a="";if((e==null?void 0:e.module)==="order"){const m=i(e.order.field_map),f=i(e.line_item.field_map),g=i(e.customer.field_map);a=m?f?g?"":"Customer Field Map":"Line Item Field Map":"Order Field Map",m&&f&&g||s({show:!0,msg:`${a} can'	 be empty`})}else(e==null?void 0:e.module)==="customer"?i(e.customer.field_map)||(a="Customer Field Map",s({show:!0,msg:p("Customer Field Map can't be empty","bit-integrations")})):(e==null?void 0:e.module)==="product"?i(e.product.field_map)||(a="Product Field Map",s({show:!0,msg:p("Product Field Map can't be empty","bit-integrations")})):(e==null?void 0:e.module)==="changestatus"&&(i(e.changestatus.field_map)||s({show:!0,msg:p("Change Status Field Map can't be empty","bit-integrations")}));setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),a===""&&u(3)};return t.jsxs("div",{children:[t.jsx(N,{snack:I,setSnackbar:s}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(L,{step:3,active:o})}),t.jsx(E,{formID:_,wcConf:e,setWcConf:n,step:o,setStep:u,isLoading:l,setIsLoading:r,setSnackbar:s}),t.jsxs("div",{className:"btcd-stp-page",style:{width:o===2&&1e3,height:o===2&&"auto"},children:[t.jsx(T,{wcConf:e,setWcConf:n,formFields:c,handleInput:a=>D(a,e,n,r,s,j),isLoading:l,setIsLoading:r}),t.jsxs("button",{onClick:C,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[p("Next","bit-integrations"),t.jsx(W,{className:"ml-1 rev-icn"})]})]}),t.jsx(P,{step:o,saveConfig:()=>B(x,h,M,e,b,"","",r),isLoading:l,dataConf:e,setDataConf:n,formFields:c})]})}export{Z as default};
