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:
parent
fc12e3cc64
commit
357b1e32e8
18 changed files with 370 additions and 82 deletions
|
|
@ -5,6 +5,7 @@ import { SessionData, sessionOptions } from '@/lib/session'
|
|||
import { prisma } from '@/lib/prisma'
|
||||
import { ProductForm } from '@/components/products/product-form'
|
||||
import { ArchiveProductButton } from '@/components/products/archive-product-button'
|
||||
import { TeamManager } from '@/components/products/team-manager'
|
||||
import { updateProductAction } from '@/actions/products'
|
||||
import Link from 'next/link'
|
||||
|
||||
|
|
@ -20,9 +21,17 @@ export default async function ProductSettingsPage({ params }: Props) {
|
|||
|
||||
const product = await prisma.product.findFirst({
|
||||
where: { id, user_id: session.userId },
|
||||
include: {
|
||||
members: {
|
||||
include: { user: { select: { id: true, username: true } } },
|
||||
orderBy: { created_at: 'asc' },
|
||||
},
|
||||
},
|
||||
})
|
||||
if (!product) notFound()
|
||||
|
||||
const members = product.members.map(m => ({ id: m.user.id, username: m.user.username }))
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-2xl mx-auto w-full">
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
|
|
@ -45,7 +54,17 @@ export default async function ProductSettingsPage({ params }: Props) {
|
|||
}}
|
||||
/>
|
||||
|
||||
<div className="mt-10 pt-6 border-t border-border">
|
||||
<div className="mt-8 pt-6 border-t border-border space-y-3">
|
||||
<div>
|
||||
<h2 className="text-sm font-medium text-foreground">Team</h2>
|
||||
<p className="text-xs text-muted-foreground mt-0.5">
|
||||
Voeg Developers toe die aan dit product mogen werken. Alleen gebruikers met de rol Developer kunnen worden toegevoegd.
|
||||
</p>
|
||||
</div>
|
||||
<TeamManager productId={id} members={members} />
|
||||
</div>
|
||||
|
||||
<div className="mt-8 pt-6 border-t border-border">
|
||||
<h2 className="text-sm font-medium text-foreground mb-3">Gevaarlijke zone</h2>
|
||||
<div className="bg-error-container/30 border border-error/20 rounded-xl p-4 flex items-center justify-between gap-4">
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue