feat(PBI-79/ST-1333): active-sprint null-contract + clearActiveSprintAction

- lib/user-settings.ts: activeSprints values nullable in Zod-schema.
  Key-aanwezigheid heeft nu betekenis (key+null = bewust geen sprint;
  key ontbreekt = fallback-cascade).
- lib/active-sprint.ts: nieuwe readStoredActiveSprintState helper +
  resolveActiveSprint respecteert expliciet 'cleared' state zonder fallback.
  clearActiveSprintInSettings schrijft null i.p.v. de key te verwijderen.
- actions/active-sprint.ts: nieuwe clearActiveSprintAction met auth +
  membership-check.
- components/shared/sprint-switcher.tsx: '— Geen actieve sprint —'-optie
  in dropdown, disabled wanneer er geen actieve sprint is.
- Tests: nieuwe active-sprint.test.ts (resolver-paden + clear),
  active-sprint-action.test.ts (action-laag), uitbreiding user-settings.test.ts.

Plan: docs/plans/PBI-79-backlog-sprint-workflow.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-05-11 13:35:32 +02:00
parent bf7162a5fc
commit 2af6f24598
9 changed files with 939 additions and 16 deletions

View file

@ -13,7 +13,7 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import { cn } from '@/lib/utils'
import { setActiveSprintAction } from '@/actions/active-sprint'
import { clearActiveSprintAction, setActiveSprintAction } from '@/actions/active-sprint'
import type { SprintStatusApi } from '@/lib/task-status'
import { debugProps } from '@/lib/debug'
@ -67,6 +67,22 @@ export function SprintSwitcher({
})
}
function handleClearActiveSprint() {
if (!activeSprint) return
startTransition(async () => {
const result = await clearActiveSprintAction(productId)
if (result?.error) {
toast.error(typeof result.error === 'string' ? result.error : 'Wisselen mislukt')
return
}
if (pathname.includes('/sprint')) {
router.push(`/products/${productId}`)
} else {
router.refresh()
}
})
}
if (sprints.length === 0) {
return (
<span {...debugProps('sprint-switcher')}>
@ -127,6 +143,17 @@ export function SprintSwitcher({
Toon afgeronde sprints
</button>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={handleClearActiveSprint}
disabled={!activeSprint || isPending}
className={cn(
'italic text-muted-foreground',
!activeSprint && 'opacity-50 cursor-not-allowed',
)}
>
Geen actieve sprint
</DropdownMenuItem>
<DropdownMenuSeparator />
{visibleSprints.length === 0 ? (
<div className="px-2 py-2 text-sm text-muted-foreground/70 italic">
Geen open sprints