feat: Todo altijd gekoppeld aan product backlog

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-04-25 12:35:40 +02:00
parent b541379964
commit cb7eb36fbb
9 changed files with 128 additions and 46 deletions

View file

@ -4,6 +4,7 @@ import { z } from 'zod'
const bodySchema = z.object({
title: z.string().min(1, 'Titel is verplicht').max(500),
product_id: z.string().min(1, 'Product is verplicht'),
})
export async function POST(request: Request) {
@ -21,9 +22,17 @@ export async function POST(request: Request) {
return Response.json({ error: parsed.error.flatten() }, { status: 400 })
}
const product = await prisma.product.findFirst({
where: { id: parsed.data.product_id, user_id: auth.userId, archived: false },
})
if (!product) {
return Response.json({ error: 'Product niet gevonden' }, { status: 404 })
}
const todo = await prisma.todo.create({
data: {
user_id: auth.userId,
product_id: parsed.data.product_id,
title: parsed.data.title,
},
})