diff --git a/components/shared/sprint-switcher.tsx b/components/shared/sprint-switcher.tsx index d000426..28edcd6 100644 --- a/components/shared/sprint-switcher.tsx +++ b/components/shared/sprint-switcher.tsx @@ -1,14 +1,15 @@ 'use client' import { usePathname, useRouter } from 'next/navigation' -import { useTransition } from 'react' -import { ChevronDown } from 'lucide-react' +import { useState, useTransition } from 'react' +import { Check, ChevronDown } from 'lucide-react' import { toast } from 'sonner' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, + DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { cn } from '@/lib/utils' @@ -40,8 +41,15 @@ export function SprintSwitcher({ const pathname = usePathname() const router = useRouter() const [isPending, startTransition] = useTransition() + const [showClosed, setShowClosed] = useState(false) const buildingSet = new Set(buildingSprintIds) + const visibleSprints = sprints.filter(s => { + if (showClosed) return true + if (s.id === activeSprint?.id) return true + return s.status === 'open' + }) + function handleSwitchSprint(sprintId: string) { if (sprintId === activeSprint?.id) return startTransition(async () => { @@ -96,27 +104,52 @@ export function SprintSwitcher({ - {sprints.map(s => ( - handleSwitchSprint(s.id)} + + + {visibleSprints.length === 0 ? ( +
+ Geen open sprints +
+ ) : ( + visibleSprints.map(s => ( + handleSwitchSprint(s.id)} className={cn( - 'text-[10px] shrink-0', - buildingSet.has(s.id) ? 'text-warning' : 'text-muted-foreground', + 'flex items-center gap-2', + s.id === activeSprint?.id && 'bg-primary-container text-primary-container-foreground font-medium', )} > - {buildingSet.has(s.id) ? 'BUILDING' : SPRINT_STATUS_LABEL[s.status]} - - - ))} + {s.code} + {s.sprint_goal} + + {buildingSet.has(s.id) ? 'BUILDING' : SPRINT_STATUS_LABEL[s.status]} + +
+ )) + )}
)