import{j as t,_ as o}from"./main.2.9.0.js";import{u as _,e as B,b as a}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{B as j}from"./BackIcn._8Wofmn2.js";import{S as y}from"./SnackMsg.DYSD96P4.js";import{I as P,g as v}from"./Integrations.DL8wqGct.js";import S from"./WebbaBookingAuthorization.ZWzGn16s.js";import{W as w,c as C}from"./WebbaBookingIntegLayout.DdcBBJ8P.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./ProUtilHelpers.CHf_DzPf.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./GlobalIntegrationHelper.B6YI8w_n.js";const I={create_booking:{key:"selectedService",msg:o("Please select a service to continue.","bit-integrations")},update_booking_status:{key:"selectedBooking",msg:o("Please select a booking to continue.","bit-integrations")},approve_booking:{key:"selectedBooking",msg:o("Please select a booking to continue.","bit-integrations")},cancel_booking:{key:"selectedBooking",msg:o("Please select a booking to continue.","bit-integrations")},delete_booking:{key:"selectedBooking",msg:o("Please select a booking to continue.","bit-integrations")},set_booking_as_paid:{key:"selectedBooking",msg:o("Please select a booking to continue.","bit-integrations")},update_coupon:{key:"selectedCoupon",msg:o("Please select a coupon to continue.","bit-integrations")},update_service:{key:"selectedService",msg:o("Please select a service to continue.","bit-integrations")}};function Q({formFields:m,setFlow:d,flow:k,allIntegURL:f}){const x=_(),{formID:b}=B(),[r,c]=a.useState(!1),[n,u]=a.useState(1),[h,s]=a.useState({show:!1}),[e,g]=a.useState({name:"Webba Booking",type:"WebbaBooking",field_map:[{formField:"",webbaBookingField:""}],actions:{},mainAction:""}),p=l=>{if(setTimeout(()=>{const i=document.getElementById("btcd-settings-wrp");i&&(i.scrollTop=0)},300),l===3){if(!e.mainAction){s({show:!0,msg:o("Please select an action to continue.","bit-integrations")});return}const i=I[e.mainAction];if(i&&!e[i.key]){s({show:!0,msg:i.msg});return}if(e.mainAction==="update_booking_status"&&!e.selectedStatus){s({show:!0,msg:o("Please select a status to continue.","bit-integrations")});return}if(!C(e)){s({show:!0,msg:o("Please map all required fields to continue.","bit-integrations")});return}e.name!==""&&e.field_map.length>0&&u(l)}else u(l)};return t.jsxs("div",{children:[t.jsx(y,{snack:h,setSnackbar:s}),t.jsx("div",{className:"txt-center mt-2"}),t.jsx(S,{formID:b,webbaBookingConf:e,setWebbaBookingConf:g,step:n,nextPage:p,isLoading:r,setIsLoading:c,setSnackbar:s}),t.jsxs("div",{className:"btcd-stp-page",style:{width:n===2&&900,height:n===2&&"auto",minHeight:n===2&&"500px"},children:[t.jsx(w,{formID:b,formFields:m,webbaBookingConf:e,setWebbaBookingConf:g,setSnackbar:s,setIsLoading:c,isLoading:r}),t.jsx("br",{}),t.jsx("br",{}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>p(3),disabled:e.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[o("Next","bit-integrations"),t.jsx(j,{className:"ml-1 rev-icn"})]})]}),t.jsx(P,{step:n,saveConfig:()=>v(k,d,f,e,x,"","",c),isLoading:r,dataConf:e,setDataConf:g,formFields:m})]})}export{Q as default};
