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 (
| Rank | Name | 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} |