import{k as F,f as v,j as t,_ as p}from"./main.2.9.0.js";import{u as y,e as k,b as l}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{B as W}from"./BackIcn._8Wofmn2.js";import{S as N}from"./SnackMsg.DYSD96P4.js";import{S as L}from"./Steps.BYe8zHkm.js";import{I as P,g as B}from"./Integrations.DL8wqGct.js";import E from"./WooCommerceAuthorization.muMuSz7W.js";import{W as T,h as D,c as i}from"./WooCommerceIntegLayout.Dri8kmvq.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function Z({formFields:c,setFlow:h,flow:b,allIntegURL:x}){const M=y(),{formID:_}=k(),S=F(v),{isPro:j}=S,[d,r]=l.useState(!1),[o,u]=l.useState(1),[I,s]=l.useState({show:!1}),[e,n]=l.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:d,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:d,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(b,h,x,e,M,"","",r),isLoading:d,dataConf:e,setDataConf:n,formFields:c})]})}export{Z as default};
