import { AlertTriangle, GitBranch, Check } from 'lucide-react' import type { Feature } from '../lib/types' import { Badge } from '@/components/ui/badge' interface DependencyBadgeProps { feature: Feature allFeatures?: Feature[] compact?: boolean } /** * Badge component showing dependency status for a feature. * Shows: * - Blocked status with count of blocking dependencies * - Dependency count for features with satisfied dependencies * - Nothing if feature has no dependencies */ export function DependencyBadge({ feature, allFeatures = [], compact = false }: DependencyBadgeProps) { const dependencies = feature.dependencies || [] if (dependencies.length === 0) { return null } // Use API-computed blocked status if available, otherwise compute locally const isBlocked = feature.blocked ?? (feature.blocking_dependencies && feature.blocking_dependencies.length > 0) ?? false const blockingCount = feature.blocking_dependencies?.length ?? 0 // Compute satisfied count from allFeatures if available let satisfiedCount = dependencies.length - blockingCount if (allFeatures.length > 0 && !feature.blocking_dependencies) { const passingIds = new Set(allFeatures.filter(f => f.passes).map(f => f.id)) satisfiedCount = dependencies.filter(d => passingIds.has(d)).length } if (compact) { // Compact view for card displays return ( {isBlocked ? ( <> {blockingCount} ) : ( <> {satisfiedCount}/{dependencies.length} )} ) } // Full view with more details return (
{isBlocked ? (
Blocked by {blockingCount} {blockingCount === 1 ? 'dependency' : 'dependencies'}
) : (
All {dependencies.length} {dependencies.length === 1 ? 'dependency' : 'dependencies'} satisfied
)}
) } /** * Small inline indicator for dependency status */ export function DependencyIndicator({ feature }: { feature: Feature }) { const dependencies = feature.dependencies || [] const isBlocked = feature.blocked || (feature.blocking_dependencies && feature.blocking_dependencies.length > 0) if (dependencies.length === 0) { return null } if (isBlocked) { return ( ) } return ( ) }