Scrum4Me/app/api/jobs/[id]/sub-tasks/route.ts
Janpeter Visser 4a63b4b01f
Sprint: UI taken/ (#149)
* feat(PBI-58): Vitest-tests voor SoloTaskCard veldmapping en 4-regels layout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(PBI-59): server action fetchJobsPageData voor jobs-pagina

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(PBI-59): SSE-route /api/realtime/jobs voor user-scoped job-events

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(PBI-59): JobCard component voor jobs-pagina

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(PBI-59): JobDetailPane component voor jobs-pagina

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* 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>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 18:41:19 +02:00

39 lines
1,020 B
TypeScript

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,
}))
)
}