feat(ST-cmovhvej7): add PBI_HAS_ACTIVE_TASKS alongside-dialoog in materialize handler

When materializeIdeaPlanAction returns code 409 with PBI_HAS_ACTIVE_TASKS:<code>,
a confirm dialog offers the user a choice: create new PBI alongside the existing one
or cancel. Alongside=true retries the action; cancel leaves the idea in PLAN_READY.
This commit is contained in:
Scrum4Me Agent 2026-05-07 15:19:54 +02:00
parent 8211b4109d
commit 9ccc57f770

View file

@ -107,15 +107,24 @@ export function IdeaRowActions({ idea, isDemo, onArchive }: IdeaRowActionsProps)
function handleMaterialize() { function handleMaterialize() {
if (!confirm('Plan materialiseren? Dit maakt PBI + stories + taken aan.')) return if (!confirm('Plan materialiseren? Dit maakt PBI + stories + taken aan.')) return
startTransition(async () => { 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) { if ('error' in r) {
toast.error(r.error) toast.error(r.error)
return return
} }
toast.success(`Gematerialiseerd als ${r.data?.pbi_code}`) 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) { if (idea.product_id) {
router.push(`/products/${idea.product_id}`) router.push(`/products/${idea.product_id}`)
} else { } else {