feat: ProductMember — team management for product backlogs

- 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>
This commit is contained in:
Janpeter Visser 2026-04-25 13:09:44 +02:00
parent fc12e3cc64
commit 357b1e32e8
18 changed files with 370 additions and 82 deletions

18
lib/product-access.ts Normal file
View file

@ -0,0 +1,18 @@
import { prisma } from '@/lib/prisma'
const accessFilter = (userId: string) => ({
OR: [
{ user_id: userId },
{ members: { some: { user_id: userId } } },
],
})
export async function getAccessibleProduct(productId: string, userId: string) {
return prisma.product.findFirst({
where: { id: productId, ...accessFilter(userId) },
})
}
export function productAccessFilter(userId: string) {
return accessFilter(userId)
}