Merge pull request #289 from femyeda/hotfix/500-on-type-page

fix: eventType not defined on [user]/[type]
pull/291/head
Bailey Pumfleet 2021-06-19 16:19:39 +01:00 committed by GitHub
commit 6d7ec7fa66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 18 deletions

View File

@ -389,29 +389,33 @@ export async function getServerSideProps(context) {
}
});
if (user) {
const eventType = await prisma.eventType.findFirst({
where: {
userId: user.id,
slug: {
equals: context.query.type,
},
},
select: {
id: true,
title: true,
description: true,
length: true
}
});
}
if (!user || !eventType) {
if (!user ) {
return {
notFound: true,
}
}
const eventType = await prisma.eventType.findFirst({
where: {
userId: user.id,
slug: {
equals: context.query.type,
},
},
select: {
id: true,
title: true,
description: true,
length: true
}
});
if (!eventType) {
return {
notFound: true
}
}
return {
props: {
user,