import type { HealthStatus } from '../types' export interface HealthStatusResult { status: HealthStatus reason?: string } export function calculateExpectedProgress( startDate: Date, endDate: Date, currentDate: Date = new Date() ): number { if (currentDate <= startDate) return 0 if (currentDate >= endDate) return 100 const totalDuration = endDate.getTime() - startDate.getTime() const elapsed = currentDate.getTime() - startDate.getTime() return Math.round((elapsed / totalDuration) * 100) } export function calculateHealthStatus( progress: number, expectedProgress: number, hasBlockers: boolean = false ): HealthStatusResult { if (hasBlockers) return { status: 'blocked', reason: 'Has active blockers' } if (progress === 0 && expectedProgress > 0) return { status: 'not_started', reason: 'Work has not started' } if (progress - expectedProgress < -10) return { status: 'at_risk', reason: 'Behind schedule' } return { status: 'on_track' } } export function getHealthColor(status: HealthStatus): string { const colors: Record = { on_track: '#22c55e', at_risk: '#eab308', blocked: '#ef4444', not_started: '#9ca3af', } return colors[status] }