CoastalCommitsPastes/client/app/admin/components/admin.tsx

40 lines
812 B
TypeScript
Raw Normal View History

import { getAllPosts, getAllUsers } from "@lib/server/prisma"
import { getCurrentUser } from "@lib/server/session"
import { notFound } from "next/navigation"
2022-04-09 20:48:19 -04:00
import styles from "./admin.module.css"
import PostTable from "./post-table"
import UserTable from "./user-table"
const Admin = async () => {
const user = await getCurrentUser()
if (!user) {
return notFound()
}
if (user.role !== "admin") {
return notFound()
}
const posts = await getAllPosts()
const users = await getAllUsers()
2022-04-09 20:48:19 -04:00
return (
<div className={styles.adminWrapper}>
<h2>Administration</h2>
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: 4
}}
>
<UserTable users={users} />
<PostTable posts={posts} />
</div>
2022-04-09 20:48:19 -04:00
</div>
)
}
2022-04-09 20:48:19 -04:00
export default Admin