Connect, collaborate, and grow with a community of TypeScript developers
Add mod view (#97)
Sean Boult07752986665e
diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsxindex dda08747..9ac44855 100644--- a/src/app/admin/page.tsx+++ b/src/app/admin/page.tsx@@ -1,30 +1,51 @@+import { RoleTypes } from '@prisma/client';import { Lock } from 'lucide-react';import { getServerSession } from 'next-auth';-import Head from 'next/head';import { authOptions } from '~/server/auth';async function Admin() {const session = await getServerSession(authOptions);+ const roles = session?.user.role ?? [];++ const isMod = roles.includes(RoleTypes.MODERATOR);+ const isAdmin = roles.includes(RoleTypes.ADMIN);+ const isModOrAdmin = isAdmin || isMod;+return (<div>- <Head>- <title>Admin</title>- </Head>- {session?.user.role.includes('ADMIN') ? (- <div className="flex flex-col">{/** Admin Content Go Here */}</div>- ) : (- <div- className="flex w-full flex-col items-center justify-center space-y-2"- style={{ minHeight: 'calc(100dvh - 112px)' }}- >- <Lock className="h-8 w-8 text-red-500" />- <span className="max-w-[40ch] text-center text-black/50 dark:text-white/50">- You do not have enough permissions to access the page.- </span>- </div>- )}+ <div className="flex flex-col items-center justify-center gap-4">+ {isModOrAdmin ? (+ <ModerationView />+ ) : (+ <div+ className="flex w-full flex-col items-center justify-center space-y-2"+ // TODO: i bet there is a css/tw way to do this, @Nikita can fix in 2ms+ style={{ minHeight: 'calc(100dvh - 112px)' }}+ >+ <Lock className="h-8 w-8" />+ <span className="max-w-[40ch] text-center text-black/50 dark:text-white/50">+ You do not have permissions to access the page.+ </span>+ </div>+ )}+ </div></div>);}+const ModerationView = async () => {+ const session = await getServerSession(authOptions);+ const roles = session?.user.role ?? [];++ return (+ <div>+ <p className="text-center text-2xl text-white">Moderation View</p>+ <div className='m-8'>+ Roles:+ <div>{JSON.stringify(roles)}</div>+ </div>+ </div>+ );+};+export default Admin;