diff --git a/pages/[user]/[type].tsx b/pages/[user]/[type].tsx index 9b825cfe6f..43edc841f3 100644 --- a/pages/[user]/[type].tsx +++ b/pages/[user]/[type].tsx @@ -370,50 +370,52 @@ export default function Type(props) { } export async function getServerSideProps(context) { - const user = await prisma.user.findFirst({ - where: { - username: context.query.user, - }, - select: { - id: true, - username: true, - name: true, - email: true, - bio: true, - avatar: true, - eventTypes: true, - startTime: true, - timeZone: true, - endTime: true, - weekStart: true, - } - }); - - if (!user) { - return { - notFound: true, - } + const user = await prisma.user.findFirst({ + where: { + username: context.query.user, + }, + select: { + id: true, + username: true, + name: true, + email: true, + bio: true, + avatar: true, + eventTypes: true, + startTime: true, + timeZone: true, + endTime: true, + weekStart: true, } + }); + if (user) { const eventType = await prisma.eventType.findFirst({ - where: { - userId: user.id, - slug: { - equals: context.query.type, - }, + where: { + userId: user.id, + slug: { + equals: context.query.type, }, - select: { - id: true, - title: true, - description: true, - length: true - } + }, + select: { + id: true, + title: true, + description: true, + length: true + } }); + } + if (!user || !eventType) { return { - props: { - user, - eventType, - }, + notFound: true, } + } + + return { + props: { + user, + eventType, + }, + } }