CoastalCommitsPastes/client/app/admin/page.tsx

23 lines
484 B
TypeScript
Raw Normal View History

2022-11-10 02:11:36 -05:00
import Admin from "@components/admin"
import { TOKEN_COOKIE_NAME } from "@lib/constants"
import { isUserAdmin } from "app/prisma"
import { cookies } from "next/headers"
import { notFound } from "next/navigation"
const AdminPage = async () => {
const driftToken = cookies().get(TOKEN_COOKIE_NAME)?.value
if (!driftToken) {
return notFound()
}
const isAdmin = await isUserAdmin(driftToken)
if (!isAdmin) {
return notFound()
}
return <Admin />
}
export default AdminPage