Move review to separate model

This commit is contained in:
2025-08-13 23:53:36 +02:00
parent befc678bdb
commit 900414727f
17 changed files with 403 additions and 155 deletions
@@ -45,23 +45,30 @@ export default defineEventHandler(async (event) => {
if (!answer) {
throw createError({ status: 404, statusText: 'Not found!' });
}
const { score, review } = await useValidatedBody(
const data = await useValidatedBody(
event,
z.object({
score: z.int().min(0).max(32767).nullable(),
review: z.string().max(256).nullable()
review: z.string().max(256).nullable(),
showcase: z.boolean().nullable().default(false),
internalNote: z.string().max(256).nullable(),
rankingValue: z.int().nullable()
})
);
await prisma.questAnswer.update({
await prisma.review.upsert({
where: {
id: answerId
answerId
},
data: {
score,
review,
update: {
...data,
reviewerId: userId
},
create: {
...data,
reviewerId: userId
}
});
return answer;
});