import api from './api' // Types for Project Health API responses export type RiskLevel = 'low' | 'medium' | 'high' | 'critical' export type ScheduleStatus = 'on_track' | 'at_risk' | 'delayed' export type ResourceStatus = 'adequate' | 'constrained' | 'overloaded' export interface ProjectHealthItem { id: string project_id: string health_score: number risk_level: RiskLevel schedule_status: ScheduleStatus resource_status: ResourceStatus last_updated: string project_title: string project_status: string owner_name: string | null space_name: string | null task_count: number completed_task_count: number blocker_count: number overdue_task_count: number } export interface ProjectHealthSummary { total_projects: number healthy_count: number // health_score >= 80 (low risk) at_risk_count: number // health_score 60-79 (medium risk) high_risk_count: number // health_score 40-59 (high risk) critical_count: number // health_score < 40 (critical risk) average_health_score: number projects_with_blockers: number projects_delayed: number } export interface ProjectHealthDashboardResponse { projects: ProjectHealthItem[] summary: ProjectHealthSummary } // API functions export const projectHealthApi = { /** * Get project health dashboard with all projects */ getDashboard: async (): Promise => { const response = await api.get('/projects/health/dashboard') return response.data }, /** * Get health status for a single project */ getProjectHealth: async (projectId: string): Promise => { const response = await api.get(`/projects/health/${projectId}`) return response.data }, } export default projectHealthApi