diff --git a/app/(protected)/admin/page.tsx b/app/(protected)/admin/page.tsx index cb5f75d..0efd268 100644 --- a/app/(protected)/admin/page.tsx +++ b/app/(protected)/admin/page.tsx @@ -1,31 +1,31 @@ -import getCurrentUserRole from "@/lib/data/current-user-role"; -import { redirect } from "next/navigation"; -import React from "react"; -import { DataTable } from "./data-table"; -import { columns } from "./columns"; +// app/(protected)/admin/page.tsx +import { Metadata } from "next"; +import { auth } from "@/auth"; import prismaDB from "@/lib/prisma"; +import UserTable from "@/components/UserTable"; -const AdminPage = async () => { - const currentUserRole = await getCurrentUserRole(); +export const metadata: Metadata = { + title: "Admin • Dashboard", + description: "Promote users to admins or block/unblock them", +}; - if (currentUserRole === "USER") { - redirect("/"); +export default async function AdminPage() { + const session = await auth(); + if (session?.user.role !== "ADMIN") { + return
Not authorized.
; } - const data = await prismaDB.user.findMany(); + // fetch all users + const users = await prismaDB.user.findMany({ + select: { id: true, name: true, email: true, role: true, isBlocked: true }, + orderBy: { email: "asc" }, + }); return ( - <> -- Browse through our collection of unprocessed deals gathered from - various sources including manual entries, bulk uploads, external - website scraping, and AI-inferred opportunities. + Browse our unprocessed deals from manual entries, bulk uploads, + website scraping, and AI inference.