- Add ProductMember model (many-to-many User ↔ Product) - Add productAccessFilter helper (owner OR member OR clause) - Replace all ownership checks across actions and API routes - Add addProductMemberAction / removeProductMemberAction / leaveProductAction - Add TeamManager component in product settings (owner adds/removes Developers) - Add LeaveProductButton in user settings (member leaves a product team) - Regenerate Prisma Client after schema migration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { authenticateApiRequest } from '@/lib/api-auth'
|
|
import { prisma } from '@/lib/prisma'
|
|
import { productAccessFilter } from '@/lib/product-access'
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const auth = await authenticateApiRequest(request)
|
|
if ('error' in auth) {
|
|
return Response.json({ error: auth.error }, { status: auth.status })
|
|
}
|
|
|
|
const { id } = await params
|
|
const url = new URL(request.url)
|
|
const limitParam = parseInt(url.searchParams.get('limit') ?? '10')
|
|
const limit = Math.min(Math.max(1, limitParam), 50)
|
|
|
|
const sprint = await prisma.sprint.findFirst({
|
|
where: { id, product: productAccessFilter(auth.userId) },
|
|
})
|
|
if (!sprint) {
|
|
return Response.json({ error: 'Sprint niet gevonden' }, { status: 404 })
|
|
}
|
|
|
|
const tasks = await prisma.task.findMany({
|
|
where: { sprint_id: id },
|
|
orderBy: [
|
|
{ story: { sort_order: 'asc' } },
|
|
{ priority: 'asc' },
|
|
{ sort_order: 'asc' },
|
|
],
|
|
take: limit,
|
|
select: { id: true, title: true, story_id: true, priority: true, sort_order: true, status: true },
|
|
})
|
|
|
|
return Response.json(tasks)
|
|
}
|