import{u as I,k as S,r as p,j as t}from"./main-406.js";import{d as F,_ as v,I as y,G as C}from"./bi.394.85.js";import{B as k}from"./bi.46.744.js";import{S as W}from"./bi.68.941.js";import N from"./bi.29.246.js";import{W as L,h as P,c as o}from"./bi.156.740.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function R({formFields:l,setFlow:g,flow:h,allIntegURL:M}){const x=I(),{formID:_}=S(),[d,r]=p.useState(!1),[i,c]=p.useState(1),[b,s]=p.useState({show:!1}),[e,n]=p.useState({name:"WooCommerce Integration",type:"WooCommerce",field_map:[],upload_field_map:[],line_field_map:[{formField:"",wcField:""}],actions:{}}),j=()=>{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(F,{snack:b,setSnackbar:s}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(W,{step:3,active:i})}),t.jsx(N,{formID:_,wcConf:e,setWcConf:n,step:i,setStep:c,isLoading:d,setIsLoading:r,setSnackbar:s}),t.jsxs("div",{className:"btcd-stp-page",style:{width:i===2&&1e3,height:i===2&&"auto"},children:[t.jsx(L,{wcConf:e,setWcConf:n,formFields:l,handleInput:a=>P(a,e,n,r,s),isLoading:d,setIsLoading:r}),t.jsxs("button",{onClick:j,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[v("Next","bit-integrations"),t.jsx(k,{className:"ml-1 rev-icn"})]})]}),t.jsx(y,{step:i,saveConfig:()=>C(h,g,M,e,x,"","",r),isLoading:d,dataConf:e,setDataConf:n,formFields:l})]})}export{R as default};
