Enhance session handling and improve data parsing; add safe date parsing utility

This commit is contained in:
2025-05-22 16:11:33 +02:00
parent efb5261c7d
commit ed6e5b0c36
11 changed files with 130 additions and 50 deletions

View File

@ -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();

View File

@ -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"
}}
/>
</div>
{isExpanded && (
<span className="text-lg font-bold text-sky-700 mt-1">LiveDash</span>
)}
</div>
{/* Toggle button */}
<div className="flex justify-center border-b border-t py-2">
<button
@ -225,7 +229,6 @@ export default function Sidebar() {
)}
</button>
</div>
{/* Navigation items */}
<nav className="flex-1 py-4 px-2 overflow-y-auto overflow-x-visible">
<NavItem
@ -279,7 +282,6 @@ export default function Sidebar() {
isActive={pathname === "/dashboard/users"}
/>
</nav>
{/* Logout at the bottom */}
<div className="p-4 border-t mt-auto">
<button

View File

@ -55,7 +55,7 @@ function formatTranscript(content: string): React.ReactNode[] {
rehypePlugins={[rehypeRaw]} // Add rehypeRaw to plugins
components={{
p: "span",
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
a: ({ node: _node, ...props }) => (
<a
className="text-sky-600 hover:text-sky-800 underline"
@ -107,7 +107,7 @@ function formatTranscript(content: string): React.ReactNode[] {
rehypePlugins={[rehypeRaw]} // Add rehypeRaw to plugins
components={{
p: "span",
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
a: ({ node: _node, ...props }) => (
<a
className="text-sky-600 hover:text-sky-800 underline"

View File

@ -53,7 +53,7 @@ export default function WordCloud({
)
.padding(5)
.rotate(() => (~~(Math.random() * 6) - 3) * 15) // Rotate between -45 and 45 degrees
.fontSize((d) => (d as any).size)
.fontSize((d: CloudWord) => d.size)
.on("end", draw);
layout.start();