import{j as e,_ as p}from"./main.2.8.1.js";import{u as j,h as S,d as a}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{B as I}from"./BackIcn._kGL_vVw.js";import{S as v}from"./SnackMsg.S8DrwLlT.js";import{S as w}from"./Steps.1hz7v9Vj.js";import{l as D,I as _,s as N}from"./Integrations.D2bgBas2.js";import Z from"./ZohoDeskAuthorization.DHl5y0Wt.js";import{h as y,c as C}from"./ZohoDeskCommonFunc.gpETZq5N.js";import{Z as F}from"./ZohoDeskIntegLayout.DBOsR8AP.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.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};
