feat(PBI-59): API route GET /api/jobs/[id]/sub-tasks voor sprint task executions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scrum4Me Agent 2026-05-07 18:40:46 +02:00
parent 0669e55175
commit fa4192a28a

View file

@ -0,0 +1,39 @@
import type { NextRequest } from 'next/server'
import { getSession } from '@/lib/auth'
import { prisma } from '@/lib/prisma'
export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const session = await getSession()
if (!session.userId) {
return Response.json({ error: 'Niet ingelogd' }, { status: 401 })
}
const userId = session.userId
const { id } = await params
const job = await prisma.claudeJob.findFirst({
where: { id, user_id: userId },
select: { kind: true },
})
if (!job || job.kind !== 'SPRINT_IMPLEMENTATION') {
return Response.json([], { status: 200 })
}
const executions = await prisma.sprintTaskExecution.findMany({
where: { sprint_job_id: id },
include: { task: { select: { code: true, title: true } } },
orderBy: { order: 'asc' },
})
return Response.json(
executions.map(e => ({
id: e.id,
taskCode: e.task.code,
taskTitle: e.task.title,
status: e.status,
}))
)
}