- Verifica se api.liveChat.listAgentSessions existe antes de renderizar - Retorna null no provider se Convex nao estiver sincronizado 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
28 lines
647 B
TypeScript
28 lines
647 B
TypeScript
"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(
|
|
() => import("./chat-widget").then((mod) => ({ default: mod.ChatWidget })),
|
|
{ ssr: false }
|
|
)
|
|
|
|
export function ChatWidgetProvider() {
|
|
// Nao renderiza se a API nao existir (Convex nao sincronizado)
|
|
if (!checkLiveChatApiExists()) {
|
|
return null
|
|
}
|
|
|
|
return <ChatWidget />
|
|
}
|