import React, { useState, useEffect } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faChevronRight, faChevronDown, } from "@fortawesome/free-solid-svg-icons"; import { formatTime } from "../lib/time"; import ScrollToBottom from "./scrollToBottom"; import DisconnectedIndicator from "./disconnectedIndicator"; import LiveTrancription from "./liveTranscription"; import FinalSummary from "./finalSummary"; import { Topic, FinalSummary as FinalSummaryType } from "./webSocketTypes"; type DashboardProps = { transcriptionText: string; finalSummary: FinalSummaryType; topics: Topic[]; disconnected: boolean; }; export function Dashboard({ transcriptionText, finalSummary, topics, disconnected, }: DashboardProps) { const [openIndex, setOpenIndex] = useState(null); const [autoscrollEnabled, setAutoscrollEnabled] = useState(true); useEffect(() => { if (autoscrollEnabled) scrollToBottom(); }, [topics.length]); const scrollToBottom = () => { const topicsDiv = document.getElementById("topics-div"); if (!topicsDiv) console.error("Could not find topics div to scroll to bottom"); else topicsDiv.scrollTop = topicsDiv.scrollHeight; }; const handleScroll = (e) => { const bottom = e.target.scrollHeight - e.target.scrollTop === e.target.clientHeight; if (!bottom && autoscrollEnabled) { setAutoscrollEnabled(false); } else if (bottom && !autoscrollEnabled) { setAutoscrollEnabled(true); } }; return ( <>

Meeting Notes

Timestamp
Topic
{topics.map((item, index) => (
setOpenIndex(openIndex === index ? null : index)} >
{formatTime(item.timestamp)}
{item.title}
{openIndex === index && (
{item.transcript}
)}
))} {topics.length === 0 && (
No topics yet
)}
{finalSummary.summary && }
{disconnected && } ); }