diff --git a/components/ideas/idea-row-actions.tsx b/components/ideas/idea-row-actions.tsx index 2b443a7..769a6cd 100644 --- a/components/ideas/idea-row-actions.tsx +++ b/components/ideas/idea-row-actions.tsx @@ -107,15 +107,24 @@ export function IdeaRowActions({ idea, isDemo, onArchive }: IdeaRowActionsProps) function handleMaterialize() { if (!confirm('Plan materialiseren? Dit maakt PBI + stories + taken aan.')) return startTransition(async () => { - const r = await materializeIdeaPlanAction(idea.id) + let r = await materializeIdeaPlanAction(idea.id) + + if ('error' in r && r.code === 409 && r.error.startsWith('PBI_HAS_ACTIVE_TASKS:')) { + const pbiCode = r.error.split(':')[1] + const alongside = confirm( + `De bestaande PBI (${pbiCode}) heeft uitgevoerde taken.\n` + + `OK = nieuwe PBI naast bestaande aanmaken.\n` + + `Annuleren = stoppen.` + ) + if (!alongside) return + r = await materializeIdeaPlanAction(idea.id, { allowAlongside: true }) + } + if ('error' in r) { toast.error(r.error) return } toast.success(`Gematerialiseerd als ${r.data?.pbi_code}`) - // Navigeer naar de product-backlog. Anchor-scrolling per-PBI bestaat - // (nog) niet in pbi-list, dus gewoon naar de overview-pagina; de nieuwe - // PBI is de meest recente. if (idea.product_id) { router.push(`/products/${idea.product_id}`) } else {