mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 08:52:10 +01:00
feat: initialize project with Next.js, Prisma, and Tailwind CSS
- Add package.json with dependencies and scripts for Next.js and Prisma - Implement API routes for session management, user authentication, and company configuration - Create database schema for Company, User, and Session models in Prisma - Set up authentication with NextAuth and JWT - Add password reset functionality and user registration endpoint - Configure Tailwind CSS and PostCSS for styling - Implement metrics and dashboard settings API endpoints
This commit is contained in:
80
components/Charts.tsx
Normal file
80
components/Charts.tsx
Normal file
@ -0,0 +1,80 @@
|
||||
'use client';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import Chart from 'chart.js/auto';
|
||||
|
||||
interface SessionsData {
|
||||
[date: string]: number;
|
||||
}
|
||||
|
||||
interface CategoriesData {
|
||||
[category: string]: number;
|
||||
}
|
||||
|
||||
interface SessionsLineChartProps {
|
||||
sessionsPerDay: SessionsData;
|
||||
}
|
||||
|
||||
interface CategoriesBarChartProps {
|
||||
categories: CategoriesData;
|
||||
}
|
||||
|
||||
// Basic line and bar chart for metrics. Extend as needed.
|
||||
export function SessionsLineChart({ sessionsPerDay }: SessionsLineChartProps) {
|
||||
const ref = useRef<HTMLCanvasElement | null>(null);
|
||||
useEffect(() => {
|
||||
if (!ref.current || !sessionsPerDay) return;
|
||||
const ctx = ref.current.getContext('2d');
|
||||
if (!ctx) return;
|
||||
|
||||
const chart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: Object.keys(sessionsPerDay),
|
||||
datasets: [
|
||||
{
|
||||
label: 'Sessions',
|
||||
data: Object.values(sessionsPerDay),
|
||||
borderWidth: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: { y: { beginAtZero: true } },
|
||||
},
|
||||
});
|
||||
return () => chart.destroy();
|
||||
}, [sessionsPerDay]);
|
||||
return <canvas ref={ref} height={180} />;
|
||||
}
|
||||
|
||||
export function CategoriesBarChart({ categories }: CategoriesBarChartProps) {
|
||||
const ref = useRef<HTMLCanvasElement | null>(null);
|
||||
useEffect(() => {
|
||||
if (!ref.current || !categories) return;
|
||||
const ctx = ref.current.getContext('2d');
|
||||
if (!ctx) return;
|
||||
|
||||
const chart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: Object.keys(categories),
|
||||
datasets: [
|
||||
{
|
||||
label: 'Categories',
|
||||
data: Object.values(categories),
|
||||
borderWidth: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: { y: { beginAtZero: true } },
|
||||
},
|
||||
});
|
||||
return () => chart.destroy();
|
||||
}, [categories]);
|
||||
return <canvas ref={ref} height={180} />;
|
||||
}
|
||||
Reference in New Issue
Block a user