From ed6e5b0c3612d36c59b8ce87987af46354e4c5b8 Mon Sep 17 00:00:00 2001 From: Kaj Kowalski Date: Thu, 22 May 2025 16:11:33 +0200 Subject: [PATCH] Enhance session handling and improve data parsing; add safe date parsing utility --- app/dashboard/company/page.tsx | 2 + app/dashboard/layout.tsx | 3 ++ app/dashboard/sessions/page.tsx | 8 +++- app/dashboard/users/page.tsx | 1 - components/DonutChart.tsx | 5 ++- components/Sidebar.tsx | 14 +++--- components/TranscriptViewer.tsx | 4 +- components/WordCloud.tsx | 2 +- lib/csvFetcher.ts | 63 +++++++++++++++++++++++---- lib/localization.ts | 2 +- pages/api/dashboard/sessions.ts | 76 +++++++++++++++++++++------------ 11 files changed, 130 insertions(+), 50 deletions(-) diff --git a/app/dashboard/company/page.tsx b/app/dashboard/company/page.tsx index c04fea1..5db649d 100644 --- a/app/dashboard/company/page.tsx +++ b/app/dashboard/company/page.tsx @@ -6,6 +6,8 @@ import { Company } from "../../lib/types"; export default function CompanySettingsPage() { const { data: session, status } = useSession(); + // We store the full company object for future use and updates after save operations + // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars const [company, setCompany] = useState(null); const [csvUrl, setCsvUrl] = useState(""); const [csvUsername, setCsvUsername] = useState(""); diff --git a/app/dashboard/layout.tsx b/app/dashboard/layout.tsx index 8afbc42..fe86322 100644 --- a/app/dashboard/layout.tsx +++ b/app/dashboard/layout.tsx @@ -6,6 +6,7 @@ import { useRouter } from "next/navigation"; import Sidebar from "../../components/Sidebar"; export default function DashboardLayout({ children }: { children: ReactNode }) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars const { data: session, status } = useSession(); const router = useRouter(); @@ -28,6 +29,8 @@ export default function DashboardLayout({ children }: { children: ReactNode }) { ); } + // Defined for potential future use, like adding a logout button in the layout + // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars const handleLogout = () => { signOut({ callbackUrl: "/login" }); }; diff --git a/app/dashboard/sessions/page.tsx b/app/dashboard/sessions/page.tsx index 90a3945..6621e31 100644 --- a/app/dashboard/sessions/page.tsx +++ b/app/dashboard/sessions/page.tsx @@ -40,7 +40,7 @@ export default function SessionsPage() { // Pagination states const [currentPage, setCurrentPage] = useState(1); const [totalPages, setTotalPages] = useState(0); - // eslint-disable-next-line @typescript-eslint/no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars const [pageSize, setPageSize] = useState(10); // Or make this configurable useEffect(() => { @@ -283,7 +283,11 @@ export default function SessionsPage() { Session ID: {session.sessionId || session.id}

- Start Time: {new Date(session.startTime).toLocaleString()} + Start Time (Local):{" "} + {new Date(session.startTime).toLocaleString()} +

+

+ Start Time (Raw API): {session.startTime.toString()}

{session.category && (

diff --git a/app/dashboard/users/page.tsx b/app/dashboard/users/page.tsx index c1addcc..57e10ec 100644 --- a/app/dashboard/users/page.tsx +++ b/app/dashboard/users/page.tsx @@ -2,7 +2,6 @@ import { useState, useEffect } from "react"; import { useSession } from "next-auth/react"; -import { UserSession } from "../../../lib/types"; interface UserItem { id: string; diff --git a/components/DonutChart.tsx b/components/DonutChart.tsx index 25d0501..87eef4a 100644 --- a/components/DonutChart.tsx +++ b/components/DonutChart.tsx @@ -77,7 +77,8 @@ export default function DonutChart({ data, centerText }: DonutChartProps) { const label = context.label || ""; const value = context.formattedValue; const total = context.chart.data.datasets[0].data.reduce( - (a: number, b: any) => a + (typeof b === "number" ? b : 0), + (a: number, b: number | string | null) => + a + (typeof b === "number" ? b : 0), 0 ); const percentage = Math.round((context.parsed * 100) / total); @@ -91,7 +92,7 @@ export default function DonutChart({ data, centerText }: DonutChartProps) { ? [ { id: "centerText", - beforeDraw: function (chart: any) { + beforeDraw: function (chart: Chart<"doughnut">) { const height = chart.height; const ctx = chart.ctx; ctx.restore(); diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index 45b83c3..6f4232d 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import Link from "next/link"; -import Image from "next/image"; // Import the Next.js Image component +import Image from "next/image"; import { usePathname } from "next/navigation"; import { signOut } from "next-auth/react"; @@ -195,16 +195,20 @@ export default function Sidebar() { src="/favicon.svg" alt="LiveDash Logo" fill - style={{ objectFit: "contain" }} className="transition-all duration-300" - priority // Added priority prop for LCP optimization + // Added priority prop for LCP optimization + priority + style={{ + objectFit: "contain", + maxWidth: "100%", + // height: "auto" + }} /> {isExpanded && ( LiveDash )} - {/* Toggle button */}

- {/* Navigation items */} - {/* Logout at the bottom */}