'use client'; import type { VelocityMetrics } from '@/services/weekly-summary'; import { Card, CardHeader, CardContent } from '@/components/ui/Card'; import { Badge } from '@/components/ui/Badge'; interface VelocityMetricsProps { velocity: VelocityMetrics; } export function VelocityMetrics({ velocity }: VelocityMetricsProps) { const getTrendIcon = (trend: number) => { if (trend > 10) return '📈'; if (trend < -10) return '📉'; return '➡️'; }; const getTrendColor = (trend: number) => { if (trend > 10) return 'text-[var(--success)]'; if (trend < -10) return 'text-[var(--destructive)]'; return 'text-[var(--muted-foreground)]'; }; const formatTrend = (trend: number) => { const sign = trend > 0 ? '+' : ''; return `${sign}${trend.toFixed(1)}%`; }; const maxActivities = Math.max(...velocity.weeklyData.map(w => w.totalActivities)); return (

⚡ Métriques de vélocité

Performance sur les 4 dernières semaines

{/* Métriques principales */}
{velocity.currentWeekTasks}
Tâches cette semaine
{velocity.previousWeekTasks}
Semaine précédente
{velocity.fourWeekAverage.toFixed(1)}
Moyenne 4 semaines
{getTrendIcon(velocity.weeklyTrend)} {formatTrend(velocity.weeklyTrend)}
Tendance
{/* Graphique de tendance simple */}

📊 Tendance sur 4 semaines

{velocity.weeklyData.map((week, index) => { const height = maxActivities > 0 ? (week.totalActivities / maxActivities) * 100 : 0; const weekLabel = `S${index + 1}`; return (
{weekLabel}
{week.totalActivities}
{new Date(week.weekStart).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })}
); })}
{/* Détails par semaine */}

📈 Détails par semaine

{velocity.weeklyData.map((week, index) => { const isCurrentWeek = index === velocity.weeklyData.length - 1; return (
Semaine du {new Date(week.weekStart).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })} {isCurrentWeek && ( Actuelle )}
{week.completedTasks} tâches {week.completedCheckboxes} daily Total: {week.totalActivities}
); })}
{/* Insights */}

💡 Insights

{velocity.weeklyTrend > 10 && (

🚀 Excellente progression ! Vous êtes {velocity.weeklyTrend.toFixed(1)}% plus productif cette semaine.

)} {velocity.weeklyTrend < -10 && (

⚠️ Baisse d'activité de {Math.abs(velocity.weeklyTrend).toFixed(1)}%. Peut-être temps de revoir votre planning ?

)} {Math.abs(velocity.weeklyTrend) <= 10 && (

✅ Rythme stable. Vous maintenez une productivité constante.

)}

📊 Votre moyenne sur 4 semaines est de {velocity.fourWeekAverage.toFixed(1)} activités par semaine.

); }