Comments, appointments adjustments, fixed some issues

This commit is contained in:
augmentedpotato
2026-04-20 19:19:30 -06:00
parent d3b9c51952
commit 2cb0a94bbb
34 changed files with 402 additions and 104 deletions

View File

@@ -6,6 +6,7 @@ import { usePathname } from "next/navigation";
import { useAuth } from "@/context/AuthContext";
import { useChatWidget } from "@/context/ChatWidgetContext";
//Floating chat button and popup window - handles AI chat, live support, and conversation history
export default function FloatingChat() {
const pathname = usePathname();
const { user, token } = useAuth();
@@ -25,6 +26,7 @@ export default function FloatingChat() {
const prevAiLengthRef = useRef(0);
const prevLiveLengthRef = useRef(0);
//Scrolls to the bottom when new messages arrive, but only if already near the bottom
useEffect(() => {
if (!isOpen) return;
const aiGrew = aiMessages.length > prevAiLengthRef.current;
@@ -41,12 +43,13 @@ const prevLiveLengthRef = useRef(0);
if (view === "history" && token && isOpen) loadConversations(token);
}, [view, token, isOpen, loadConversations]);
// Hide widget on dedicated chat pages
//Don't show the widget on the full chat pages since they have their own UI
if (pathname === "/ai-chat" || pathname === "/chat") return null;
const openConvCount = conversations.filter((c) => c.status === "OPEN").length;
const isLiveClosed = activeConv?.status === "CLOSED";
//Sends the typed message to whichever chat is currently active
async function handleSend(e) {
e?.preventDefault();
const text = input.trim();
@@ -358,7 +361,7 @@ const prevLiveLengthRef = useRef(0);
);
}
// Styles
//Inline style objects for the floating chat widget
const s = {
fab: {
position: "fixed", bottom: 24, right: 24,