import{u as S,k as v,h as y,r as d,j as t}from"./main-333.js";import{j as C,d as k,_ as W,I as N,F as L}from"./bi.636.93.js";import{B as P}from"./bi.429.767.js";import{S as B}from"./bi.563.969.js";import E from"./bi.673.257.js";import{W as T,h as D,c as o}from"./bi.301.763.js";import"./bi.318.783.js";import"./bi.535.730.js";import"./bi.286.731.js";function J({formFields:p,setFlow:g,flow:h,allIntegURL:x}){const M=S(),{formID:b}=v(),_=y(C),{isPro:j}=_,[l,r]=d.useState(!1),[i,c]=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:{}}),F=()=>{let a="";if((e==null?void 0:e.module)==="order"){const m=o(e.order.field_map),u=o(e.line_item.field_map),f=o(e.customer.field_map);a=m?u?f?"":"Customer Field Map":"Line Item Field Map":"Order Field Map",m&&u&&f||s({show:!0,msg:`${a} can'	 be empty`})}else(e==null?void 0:e.module)==="customer"?o(e.customer.field_map)||(a="Customer Field Map",s({show:!0,msg:"Customer Field Map can't be empty"})):(e==null?void 0:e.module)==="product"?o(e.product.field_map)||(a="Product Field Map",s({show:!0,msg:"Product Field Map can't be empty"})):(e==null?void 0:e.module)==="changestatus"&&(o(e.changestatus.field_map)||s({show:!0,msg:"Change Status Field Map can't be empty"}));setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),a===""&&c(3)};return t.jsxs("div",{children:[t.jsx(k,{snack:I,setSnackbar:s}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(B,{step:3,active:i})}),t.jsx(E,{formID:b,wcConf:e,setWcConf:n,step:i,setStep:c,isLoading:l,setIsLoading:r,setSnackbar:s}),t.jsxs("div",{className:"btcd-stp-page",style:{width:i===2&&1e3,height:i===2&&"auto"},children:[t.jsx(T,{wcConf:e,setWcConf:n,formFields:p,handleInput:a=>D(a,e,n,r,s,j),isLoading:l,setIsLoading:r}),t.jsxs("button",{onClick:F,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[W("Next","bit-integrations"),t.jsx(P,{className:"ml-1 rev-icn"})]})]}),t.jsx(N,{step:i,saveConfig:()=>L(h,g,x,e,M,"","",r),isLoading:l,dataConf:e,setDataConf:n,formFields:p})]})}export{J as default};
