'use client'; import { PERIOD_OPTIONS, PeriodOption, PeriodComparison } from '@/services/weekly-summary'; import { Card, CardHeader, CardContent } from '@/components/ui/Card'; import { Button } from '@/components/ui/Button'; interface PeriodSelectorProps { currentPeriod: PeriodOption; onPeriodChange: (period: PeriodOption) => void; comparison: PeriodComparison | null; isLoading?: boolean; } export function PeriodSelector({ currentPeriod, onPeriodChange, comparison, isLoading = false }: PeriodSelectorProps) { const formatChange = (change: number): string => { const sign = change > 0 ? '+' : ''; return `${sign}${change.toFixed(1)}%`; }; const getChangeColor = (change: number): string => { if (change > 10) return 'text-[var(--success)]'; if (change < -10) return 'text-[var(--destructive)]'; return 'text-[var(--muted-foreground)]'; }; const getChangeIcon = (change: number): string => { if (change > 10) return '📈'; if (change < -10) return '📉'; return '➡️'; }; return (

📊 Sélection de période

{PERIOD_OPTIONS.map((option) => ( ))}
{comparison && (
{/* Titre de comparaison */}

Comparaison avec la période précédente

{/* Métriques de comparaison */}
{/* Tâches */}
Tâches complétées {getChangeIcon(comparison.changes.tasks)} {formatChange(comparison.changes.tasks)}
Actuelle: {comparison.currentPeriod.tasks} Précédente: {comparison.previousPeriod.tasks}
{/* Daily items */}
Daily items {getChangeIcon(comparison.changes.checkboxes)} {formatChange(comparison.changes.checkboxes)}
Actuelle: {comparison.currentPeriod.checkboxes} Précédente: {comparison.previousPeriod.checkboxes}
{/* Total */}
Total activités {getChangeIcon(comparison.changes.total)} {formatChange(comparison.changes.total)}
Actuelle: {comparison.currentPeriod.total} Précédente: {comparison.previousPeriod.total}
{/* Insights sur la comparaison */}
💡 Insights comparatifs
{comparison.changes.total > 15 && (

🚀 Excellente progression ! Productivité en hausse de {formatChange(comparison.changes.total)}.

)} {comparison.changes.total < -15 && (

📉 Baisse d'activité de {formatChange(Math.abs(comparison.changes.total))}. Période moins chargée ?

)} {Math.abs(comparison.changes.total) <= 15 && (

✅ Rythme stable maintenu entre les deux périodes.

)} {comparison.changes.tasks > comparison.changes.checkboxes + 10 && (

🎯 Focus accru sur les tâches importantes cette période.

)} {comparison.changes.checkboxes > comparison.changes.tasks + 10 && (

📝 Activité quotidienne plus intense cette période.

)}

📊 Évolution globale: {comparison.currentPeriod.total} activités vs {comparison.previousPeriod.total} la période précédente.

)}
); }