* feat(tooling): extend backlog parser to support PBI-x milestone headers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore(backlog): mark ST-801–806 as done Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(backlog): sorteer PBI's en stories op prio/code/datum, onthoud keuze in localStorage; vergroot sprint-afronden dialoog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-901): add user.active_product_id with FK to Product - Nullable relation User → Product with onDelete: SetNull - Index on active_product_id for join performance - Migration: 20260427165329_add_user_active_product_id - Install @tanstack/react-table (was missing from node_modules) - Fix PRIORITY_COLORS ref removed in earlier refactor - Note: User schema change affects vendor/scrum4me-mcp submodule — run prisma generate + tsc --noEmit there after merge Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: restore priority color on PBI filter pill Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-902): add setActiveProduct + clearActiveProduct server actions - actions/active-product.ts: setActiveProductAction validates access via productAccessFilter, rejects archived products and demo users - archiveProductAction: clears active_product_id for all affected users in transaction - removeProductMemberAction: clears active_product_id for removed member - leaveProductAction: clears active_product_id for leaving user Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-903): load active product in layout, replace cookie with DB lookup in solo - layout.tsx: fetch active_product_id, resolve product, clear stale ref server-side - NavBar: add activeProduct prop (rendering changes in ST-904) - solo/page.tsx: redirect via user.active_product_id instead of lastProductId cookie - proxy.ts: remove lastProductId cookie logic - lib/cookies.ts: deleted (no longer used) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-904): split NavBar into 5 tabs with disabled-states and product-switcher dropdown Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-905): add Activeer button per product row in dashboard and product header * feat(ST-906): redirect to dashboard with toast when active product becomes inaccessible * feat(ST-907): tests for active-product actions and functional spec update for M9 * docs(M9): add implementation plan document and link from backlog * feat: active PB indicator, Maak actief button and new product link in settings * feat: apply priority-color card style to sprint story rows * fix: move add-to-sprint click from entire card to + Toevoegen button * feat: apply priority-color card style to sprint task rows * fix(sprint-backlog): prevent text selection on PBI collapse button * chore: bump version to 0.4.0 (M9 active product backlog) * fix(landing): align logged-in nav left to match app NavBar --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
128 lines
4.5 KiB
TypeScript
128 lines
4.5 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/navigation'
|
|
import { useTransition } from 'react'
|
|
import { toast } from 'sonner'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Badge } from '@/components/ui/badge'
|
|
import { CodeBadge } from '@/components/shared/code-badge'
|
|
import { restoreProductAction } from '@/actions/products'
|
|
import { setActiveProductAction } from '@/actions/active-product'
|
|
|
|
interface Product {
|
|
id: string
|
|
name: string
|
|
code: string | null
|
|
description: string | null
|
|
repo_url: string | null
|
|
}
|
|
|
|
interface ProductListProps {
|
|
products: Product[]
|
|
isDemo: boolean
|
|
showArchived?: boolean
|
|
activeProductId: string | null
|
|
}
|
|
|
|
export function ProductList({ products, isDemo, showArchived = false, activeProductId }: ProductListProps) {
|
|
const router = useRouter()
|
|
const [, startTransition] = useTransition()
|
|
|
|
function handleRestore(id: string) {
|
|
startTransition(async () => {
|
|
const result = await restoreProductAction(id)
|
|
if ('error' in result) toast.error(result.error ?? 'Herstellen mislukt')
|
|
else { toast.success('Product hersteld'); router.refresh() }
|
|
})
|
|
}
|
|
|
|
function handleActivate(id: string) {
|
|
if (isDemo) { toast.error('Niet beschikbaar in demo-modus'); return }
|
|
startTransition(async () => {
|
|
const result = await setActiveProductAction(id)
|
|
if (result?.error) toast.error(typeof result.error === 'string' ? result.error : 'Activeren mislukt')
|
|
else router.push(`/products/${id}`)
|
|
})
|
|
}
|
|
|
|
if (products.length === 0) {
|
|
return (
|
|
<div className="bg-surface-container-low rounded-xl border border-border p-12 text-center space-y-3">
|
|
<p className="text-muted-foreground">
|
|
{showArchived
|
|
? 'Geen gearchiveerde producten.'
|
|
: 'Je hebt nog geen producten aangemaakt.'}
|
|
</p>
|
|
{!isDemo && !showArchived && (
|
|
<Button variant="outline" nativeButton={false} render={<Link href="/products/new" />}>
|
|
Maak je eerste product aan
|
|
</Button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className="grid gap-3">
|
|
{products.map(product => (
|
|
<div
|
|
key={product.id}
|
|
onClick={() => !showArchived && router.push(`/products/${product.id}`)}
|
|
className={`group bg-surface-container-low border border-border rounded-xl p-4 transition-colors ${
|
|
showArchived ? 'opacity-60' : 'cursor-pointer hover:border-primary'
|
|
}`}
|
|
>
|
|
<div className="flex items-start justify-between gap-4">
|
|
<div className="min-w-0">
|
|
<div className="flex items-center gap-2">
|
|
{product.code && <CodeBadge code={product.code} />}
|
|
<p className="font-medium text-foreground group-hover:text-primary transition-colors truncate">
|
|
{product.name}
|
|
</p>
|
|
</div>
|
|
{product.description && (
|
|
<p className="text-sm text-muted-foreground mt-1 line-clamp-1">
|
|
{product.description.slice(0, 80)}{product.description.length > 80 ? '…' : ''}
|
|
</p>
|
|
)}
|
|
</div>
|
|
<div className="flex items-center gap-3 shrink-0">
|
|
{product.repo_url && (
|
|
<a
|
|
href={product.repo_url}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
onClick={e => e.stopPropagation()}
|
|
className="text-xs text-muted-foreground hover:text-primary underline"
|
|
>
|
|
Repo
|
|
</a>
|
|
)}
|
|
{!showArchived && (
|
|
product.id === activeProductId
|
|
? <Badge className="bg-primary-container text-primary-container-foreground text-xs px-2 py-0">Actief</Badge>
|
|
: (
|
|
<button
|
|
onClick={(e) => { e.stopPropagation(); handleActivate(product.id) }}
|
|
className="text-xs text-primary hover:underline"
|
|
>
|
|
Activeer
|
|
</button>
|
|
)
|
|
)}
|
|
{showArchived && !isDemo && (
|
|
<button
|
|
onClick={(e) => { e.stopPropagation(); handleRestore(product.id) }}
|
|
className="text-xs text-primary hover:underline"
|
|
>
|
|
Herstellen
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|