import { auth } from "@/lib/auth" import { redirect } from "next/navigation" import { prisma } from "@/lib/prisma" // Enable caching for this page export const revalidate = 30 // Revalidate every 30 seconds export default async function LeaderboardPage() { const session = await auth() if (!session) { redirect("/login") } const users = await prisma.user.findMany({ orderBy: { points: "desc" }, select: { id: true, name: true, email: true, points: true, role: true, }, }) return (

Leaderboard

{users.map((user: { id: string; name: string; email: string; points: number; role: string }, index: number) => ( ))}
Rank Name Email Points
{index === 0 ? "🥇" : index === 1 ? "🥈" : index === 2 ? "🥉" : `#${index + 1}`} {user.name} {user.role === "ADMIN" && ( Admin )} {user.id === session.user.id && ( You )} {user.email} {user.points}
) }