import Link from "next/link"
import { ArrowRightIcon } from "@radix-ui/react-icons"
import { Line } from "react-chartjs-2"
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
} from 'chart.js'
import { Button } from "@/components/ui/button"
// Register ChartJS components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
)
export default async function DashboardHome() {
// Sample data - replace this with your actual data fetching logic
const chartData = {
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
datasets: [
{
label: 'Open Requests',
data: [12, 19, 3, 5, 2, 3],
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
}
]
}
const chartOptions = {
responsive: true,
plugins: {
legend: {
position: 'top' as const,
},
title: {
display: true,
text: 'Open Requests Over Time'
}
}
}
return (
<div className="flex flex-1 flex-grow flex-col gap-4 lg:gap-6">
{/* Chart Section */}
<div className="flex-1 rounded-3xl border bg-field p-6 shadow-sm">
<div className="h-[300px]">
<Line options={chartOptions} data={chartData} />
</div>
</div>
{/* Existing Content */}
<div className="flex flex-1 items-center justify-center rounded-3xl border bg-field shadow-sm">
<div className="flex max-w-[500px] flex-col items-center gap-1 text-center">
<h3 className="text-2xl font-bold tracking-tight">
Explore the SaaS Starter
</h3>
<p className="mt-3 text-muted-foreground">
This reference app demonstrates how to build a multi-tenant B2B SaaS
application powered by Auth0 by Okta.
</p>
<p className="mt-3 text-muted-foreground">
Head over to the Settings Dashboard to explore common administrative
capabilities like membership management, single sign-on
configuration, and security policies.
</p>
<div className="mt-8">
<Link href="/dashboard/organization/general" className="w-full">
<Button className="w-full">
Navigate to Settings
<ArrowRightIcon className="ml-2 size-4" />
</Button>
</Link>
</div>
<p className="mt-3 text-muted-foreground">
(You must be logged in with an "admin" role in your
organization.)
</p>
</div>
</div>
</div>
)
}
The chart will automatically update when the data changes, and it maintains the clean, modern look of the existing dashboard while adding useful visualization of the open requests.