Refactoring beer by id page, add delete comment

Refactored the comments ui into various new components, added the delete beer comment by id feature.
This commit is contained in:
Aaron William Po
2023-03-03 21:19:18 -05:00
parent 4a6e10572c
commit 472ead9abd
16 changed files with 331 additions and 136 deletions

View File

@@ -1,11 +1,21 @@
import { GetServerSideProps, GetServerSidePropsContext, Redirect } from 'next';
import { getLoginSession } from '@/config/auth/session';
import findUserById from '@/services/User/findUserById';
const redirectIfLoggedIn = (redirect: Redirect) => {
const fn: GetServerSideProps = async (context: GetServerSidePropsContext) => {
try {
const { req } = context;
await getLoginSession(req);
const session = await getLoginSession(req);
const { id } = session;
const user = await findUserById(id);
if (!user) {
throw new Error('Could not get user.');
}
return { redirect };
} catch {
return { props: {} };