diff --git a/src/components/chat/chat-widget-provider.tsx b/src/components/chat/chat-widget-provider.tsx index 4847834..3ebbe09 100644 --- a/src/components/chat/chat-widget-provider.tsx +++ b/src/components/chat/chat-widget-provider.tsx @@ -1,6 +1,16 @@ "use client" import dynamic from "next/dynamic" +import { api } from "@/convex/_generated/api" + +// Verifica se a API do liveChat existe +function checkLiveChatApiExists() { + try { + return typeof api.liveChat?.listAgentSessions !== "undefined" + } catch { + return false + } +} // Importacao dinamica para evitar problemas de SSR const ChatWidget = dynamic( @@ -9,5 +19,10 @@ const ChatWidget = dynamic( ) export function ChatWidgetProvider() { + // Nao renderiza se a API nao existir (Convex nao sincronizado) + if (!checkLiveChatApiExists()) { + return null + } + return } diff --git a/src/components/chat/chat-widget.tsx b/src/components/chat/chat-widget.tsx index f646aa8..30818e6 100644 --- a/src/components/chat/chat-widget.tsx +++ b/src/components/chat/chat-widget.tsx @@ -13,6 +13,7 @@ import { MessageCircle, Send, X, Minimize2, User, Headphones, ChevronDown } from const MAX_MESSAGE_LENGTH = 4000 + function formatTime(timestamp: number) { return new Date(timestamp).toLocaleTimeString("pt-BR", { hour: "2-digit",