import{h as m,$ as h,g as S,k as I,i as y,j as r,_ as t,q as s}from"./main.2.9.0.js";import{u as N,e as R,b as l}from"./react-router.DMwpH23k.js";import{S as _}from"./SnackMsg.DYSD96P4.js";import"./Note.NSUdvR3c.js";import"./CopyIcn.CEA_lFLo.js";import{S as w,I as L,s as v}from"./Integrations.DL8wqGct.js";import{h as f,c as u}from"./PerfexCRMCommonFunc.G_UNPdBU.js";import{P as F}from"./PerfexCRMIntegLayout.Cp8T0GYm.js";import"./react-vendor.P7K3d6op.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function O({allIntegURL:p}){const g=N(),{id:M}=R(),[o,T]=m(h),[e,i]=m(S),[b,d]=l.useState(!1),[x,P]=l.useState({}),[j,a]=l.useState({show:!1}),c=I(y),C=()=>{if(!u(e)){a({show:!0,msg:t("Please map mandatory fields","bit-integrations")});return}if(e.actionName==="contact"&&!e.selectedCustomer){s.error(t("Please select a Customer","bit-integrations"));return}if(e.actionName==="lead"&&(!e.selectedLeadStatusId||!e.selectedLeadSourceId||!e.selectedStaff)){s.error(t("Lead Status Id and Lead Source Id are required!","bit-integrations"));return}if(e.actionName==="project"){if(!e.selectedProjectStatus){s.error(t("Please select Project status","bit-integrations"));return}if(!e.selectedProjectType){s.error(t("Please select Project Related With...","bit-integrations"));return}if(!e.selectedbillingType){s.error(t("Please select a Billing type","bit-integrations"));return}if(!e.selectedCustomer){s.error(t("Please select a Customer","bit-integrations"));return}if(Number(e.selectedbillingType)===1&&!e.totalRate){s.error(t("Please select a Total Rate","bit-integrations"));return}if(Number(e.selectedbillingType)===2&&!e.ratePerHour){s.error(t("Please select a Rate Per Hour","bit-integrations"));return}}v({flow:o,allIntegURL:p,conf:e,navigate:g,edit:1,setIsLoading:d,setSnackbar:a})};return r.jsxs("div",{style:{width:900},children:[r.jsx(_,{snack:j,setSnackbar:a}),r.jsxs("div",{className:"flx mt-3",children:[r.jsx("b",{className:"wdt-200 d-in-b",children:t("Integration Name:","bit-integrations")}),r.jsx("input",{className:"btcd-paper-inp w-5",onChange:n=>f(n,e,i),name:"name",value:e.name,type:"text",placeholder:t("Integration Name...","bit-integrations")})]}),r.jsx("br",{}),r.jsx(w,{entity:o.triggered_entity,setSnackbar:a}),r.jsx(F,{formID:o.triggered_entity_id,formFields:c,handleInput:n=>f(n,e,i),perfexCRMConf:e,setPerfexCRMConf:i,loading:x,setLoading:P,setIsLoading:d,setSnackbar:a}),r.jsx(L,{edit:!0,saveConfig:C,disabled:!u(e),isLoading:b,dataConf:e,setDataConf:i,formFields:c}),r.jsx("br",{})]})}export{O as default};
