import{j as e,_ as p}from"./main.2.8.10.js";import{u as j,e as S,b as a}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{B as I}from"./BackIcn.BFDZx8No.js";import{S as v}from"./SnackMsg.7BjcJK1j.js";import{S as w}from"./Steps.B84Ui3GU.js";import{l as D,I as _,s as N}from"./Integrations.BFhED4ck.js";import Z from"./ZohoDeskAuthorization.CuoohbM1.js";import{h as y,c as C}from"./ZohoDeskCommonFunc.HGbTsWRd.js";import{Z as F}from"./ZohoDeskIntegLayout.DCQdhgsS.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function V({formFields:f,setFlow:h,flow:u,allIntegURL:g}){const x=j(),{formID:i}=S(),[c,n]=a.useState(!1),[o,l]=a.useState(1),[k,s]=a.useState({show:!1}),[t,r]=a.useState({name:"Zoho Desk",type:"Zoho Desk",clientId:"",clientSecret:"",orgId:"",department:"",field_map:[{formField:"",zohoFormField:""}],actions:{}});a.useEffect(()=>{window.opener&&D("zohoDesk")},[]);const b=m=>{var d;{if(!C(t)){s({show:!0,msg:p("Please map mandatory fields","bit-integrations")});return}if(!((d=t.actions)!=null&&d.ticket_owner)){s({show:!0,msg:p("Please select a ticket owner","bit-integrations")});return}t.department!==""&&t.table!==""&&t.field_map.length>0&&l(m)}};return e.jsxs("div",{children:[e.jsx(v,{snack:k,setSnackbar:s}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(w,{step:3,active:o})}),e.jsx(Z,{formID:i,deskConf:t,setDeskConf:r,step:o,setstep:l,isLoading:c,setIsLoading:n,setSnackbar:s}),e.jsxs("div",{className:"btcd-stp-page",style:{width:o===2&&900,height:o===2&&"auto"},children:[e.jsx(F,{formID:i,formFields:f,handleInput:m=>y(m,t,r,i,n,s),deskConf:t,setDeskConf:r,isLoading:c,setIsLoading:n,setSnackbar:s}),e.jsxs("button",{onClick:()=>b(3),disabled:t.department===""||t.table===""||t.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[p("Next","bit-integrations"),e.jsx(I,{className:"ml-1 rev-icn"})]})]}),e.jsx(_,{step:o,saveConfig:()=>N({flow:u,setFlow:h,allIntegURL:g,navigate:x,conf:t,setIsLoading:n,setSnackbar:s})})]})}export{V as default};
