Add diashow and styling

This commit is contained in:
2025-08-17 01:40:30 +02:00
parent 0e4015905c
commit c35fb06830
9 changed files with 480 additions and 74 deletions
+105
View File
@@ -0,0 +1,105 @@
import { useValidatedParams, z, zh } from 'h3-zod';
import prisma from '~~/lib/prisma';
export default defineEventHandler(async (event) => {
const { huntId } = await useValidatedParams(
event,
z.object({
huntId: zh.numAsString
})
);
const user = await getUserSession(event);
const userId = user.user?.id || 0;
// TODO: use one request for this logic
const exists = await prisma.hunt.findUnique({
where: {
id: huntId,
deletedAt: null
},
select: { id: true }
});
if (!exists) {
throw createError({ status: 404, statusText: 'Not found!' });
}
const hunt = await prisma.hunt.findUnique({
where: {
id: huntId,
deletedAt: null,
OR: [
{
revealAnswers: true,
revealQuests: true
},
{
creatorId: userId
},
{
members: {
some: {
memberId: userId
}
}
}
]
},
select: {
id: true,
name: true,
quests: {
select: {
id: true,
title: true,
answers: {
select: {
team: {
select: {
id: true,
name: true
}
},
picture: {
select: {
url: true,
creator: {
select: {
name: true
}
}
}
}
},
where: {
final: true,
picture: {
isNot: null
}
}
}
},
where: {
answers: {
some: {
final: true,
picture: {
isNot: null
}
}
}
}
}
}
});
if (!hunt) {
throw createError({
status: 403,
statusText: 'Answers are not revealed yet!'
});
}
return hunt;
});