'use client' // IdeaPbiLinkCard — toont de gekoppelde PBI bij PLANNED. Bij "stale link" // (status===PLANNED maar pbi_id===null, want PBI elders verwijderd via // de SetNull FK) tonen we de Re-link-banner. import { useTransition } from 'react' import Link from 'next/link' import { useRouter } from 'next/navigation' import { ExternalLink, Link2Off } from 'lucide-react' import { toast } from 'sonner' import { Button } from '@/components/ui/button' import { debugProps } from '@/lib/debug' import { relinkIdeaPlanAction } from '@/actions/ideas' import type { IdeaDto } from '@/lib/idea-dto' interface Props { idea: IdeaDto isDemo: boolean } export function IdeaPbiLinkCard({ idea, isDemo }: Props) { const router = useRouter() const [pending, startTransition] = useTransition() if (idea.status !== 'planned') return null if (idea.pbi && idea.product_id) { return (

Gepland

Gematerialiseerd als{' '} {idea.pbi.code} — {idea.pbi.title}

) } // Stale link — pbi_id === null maar status nog PLANNED. function handleRelink() { if (isDemo) return startTransition(async () => { const r = await relinkIdeaPlanAction(idea.id) if ('error' in r) { toast.error(r.error) return } toast.success('Idee terug naar PLAN_READY — open de Plan-tab.') router.refresh() }) } return (

De gekoppelde PBI bestaat niet meer

Klik om dit idee terug naar PLAN_READY te zetten en opnieuw te materialiseren.

) }