import { getAllPosts, getAllUsers } from "@lib/server/prisma" import { Spinner } from "@components/spinner" import styles from "./admin.module.css" export function UserTable({ users }: { users?: Awaited> }) { return ( {users?.map((user) => ( ))} {!users && ( )}
Name Email Role User ID
{user.name ? user.name : "no name"} {user.email} {user.role} {user.id}
) } export function PostTable({ posts }: { posts?: Awaited> }) { return ( {posts?.map((post) => ( ))} {!posts && ( )}
Title Author Created Visibility Post ID
{post.title} {"author" in post ? post.author.name : "no author"} {post.createdAt.toLocaleDateString()} {post.visibility} {post.id}
) } export default async function AdminPage() { const usersPromise = getAllUsers() const postsPromise = getAllPosts({ withAuthor: true }) const [users, posts] = await Promise.all([usersPromise, postsPromise]) return (

Admin

Users

Posts

) }