diff --git a/apps/dokploy/components/layouts/dashboard-layout.tsx b/apps/dokploy/components/layouts/dashboard-layout.tsx index 0bc39baf..4e2e15b3 100644 --- a/apps/dokploy/components/layouts/dashboard-layout.tsx +++ b/apps/dokploy/components/layouts/dashboard-layout.tsx @@ -1,6 +1,7 @@ import { api } from "@/utils/api"; import { ImpersonationBar } from "../dashboard/impersonation/impersonation-bar"; import Page from "./side"; +import { ChatwootWidget } from "../shared/ChatwootWidget"; interface Props { children: React.ReactNode; @@ -9,10 +10,15 @@ interface Props { export const DashboardLayout = ({ children }: Props) => { const { data: haveRootAccess } = api.user.haveRootAccess.useQuery(); + const { data: isCloud } = api.settings.isCloud.useQuery(); return ( <> {children} + {isCloud === true && ( + + )} + {haveRootAccess === true && } ); diff --git a/apps/dokploy/components/layouts/project-layout.tsx b/apps/dokploy/components/layouts/project-layout.tsx deleted file mode 100644 index f5fdf350..00000000 --- a/apps/dokploy/components/layouts/project-layout.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Page from "./side"; - -interface Props { - children: React.ReactNode; -} - -export const ProjectLayout = ({ children }: Props) => { - return {children}; -}; diff --git a/apps/dokploy/components/shared/ChatwootWidget.tsx b/apps/dokploy/components/shared/ChatwootWidget.tsx new file mode 100644 index 00000000..6694b13c --- /dev/null +++ b/apps/dokploy/components/shared/ChatwootWidget.tsx @@ -0,0 +1,69 @@ +import Script from "next/script"; +import { useEffect } from "react"; + +interface ChatwootWidgetProps { + websiteToken: string; + baseUrl?: string; + settings?: { + position?: "left" | "right"; + type?: "standard" | "expanded_bubble"; + launcherTitle?: string; + darkMode?: boolean; + hideMessageBubble?: boolean; + placement?: "right" | "left"; + showPopoutButton?: boolean; + widgetStyle?: "standard" | "bubble"; + }; + user?: { + identifier: string; + name?: string; + email?: string; + phoneNumber?: string; + avatarUrl?: string; + customAttributes?: Record; + identifierHash?: string; + }; +} + +export const ChatwootWidget = ({ + websiteToken, + baseUrl = "https://app.chatwoot.com", + settings = { + position: "right", + type: "standard", + launcherTitle: "Chat with us", + }, + user, +}: ChatwootWidgetProps) => { + useEffect(() => { + // Configurar los settings de Chatwoot + window.chatwootSettings = { + position: "right", + }; + + (window as any).chatwootSDKReady = () => { + window.chatwootSDK?.run({ websiteToken, baseUrl }); + + const trySetUser = () => { + if (window.$chatwoot && user) { + window.$chatwoot.setUser(user.identifier, { + email: user.email, + name: user.name, + avatar_url: user.avatarUrl, + phone_number: user.phoneNumber, + }); + } + }; + + trySetUser(); + }; + }, [websiteToken, baseUrl, user, settings]); + + return ( +