diff --git a/components/ideas/download-md-button.tsx b/components/ideas/download-md-button.tsx new file mode 100644 index 0000000..6e1a255 --- /dev/null +++ b/components/ideas/download-md-button.tsx @@ -0,0 +1,55 @@ +'use client' + +// DownloadMdButton — download grill_md of plan_md als .md-bestand. +// Demo MAG downloaden (read-only). Server-action returnt md-string; client +// bouwt een Blob + anchor + click(). + +import { useTransition } from 'react' +import { Download } from 'lucide-react' +import { toast } from 'sonner' + +import { Button } from '@/components/ui/button' +import { downloadIdeaMdAction } from '@/actions/ideas' + +interface Props { + ideaId: string + kind: 'grill' | 'plan' + hasContent: boolean +} + +export function DownloadMdButton({ ideaId, kind, hasContent }: Props) { + const [pending, startTransition] = useTransition() + + function handleClick() { + startTransition(async () => { + const r = await downloadIdeaMdAction(ideaId, kind) + if ('error' in r) { + toast.error(r.error) + return + } + if (!r.data) return + const blob = new Blob([r.data.markdown], { type: 'text/markdown;charset=utf-8' }) + const url = URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = r.data.filename + document.body.appendChild(a) + a.click() + a.remove() + URL.revokeObjectURL(url) + }) + } + + return ( + + ) +} diff --git a/components/ideas/idea-detail-layout.tsx b/components/ideas/idea-detail-layout.tsx index d46b126..0e12ac8 100644 --- a/components/ideas/idea-detail-layout.tsx +++ b/components/ideas/idea-detail-layout.tsx @@ -23,6 +23,9 @@ import type { IdeaDto } from '@/lib/idea-dto' import { updateIdeaAction, archiveIdeaAction } from '@/actions/ideas' import { IdeaRowActions } from '@/components/ideas/idea-row-actions' import { IdeaMdEditor } from '@/components/ideas/idea-md-editor' +import { IdeaPbiLinkCard } from '@/components/ideas/idea-pbi-link-card' +import { IdeaTimeline } from '@/components/ideas/idea-timeline' +import { DownloadMdButton } from '@/components/ideas/download-md-button' const API_TO_DB: Record[0]> = { draft: 'DRAFT', @@ -153,32 +156,8 @@ export function IdeaDetailLayout({ - {/* PBI-link card bij PLANNED — placeholder voor T-512 */} - {idea.status === 'planned' && idea.pbi && ( -
-

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

-
- )} - {idea.status === 'planned' && !idea.pbi && ( -
-

- De gekoppelde PBI bestaat niet meer. Klik om dit idee terug naar - PLAN_READY te zetten en opnieuw te materialiseren. -

-
- )} + {/* PBI-link card / Re-link banner bij PLANNED */} + {/* Tab-switcher */}