refactor: remove deprecated weekly summary components and related services
- Deleted `WeeklySummaryClient`, `VelocityMetrics`, `PeriodSelector`, and associated services to streamline the codebase. - Removed the `weekly-summary` API route and related PDF export functionality, as these features are no longer in use. - Updated `TODO.md` to reflect the removal of these components and their functionalities.
This commit is contained in:
128
TODO.md
128
TODO.md
@@ -305,134 +305,6 @@ Endpoints complexes → API Routes conservées
|
||||
- [x] Vue détaillée par sprint avec drill-down
|
||||
- [x] ~~Intégration avec les daily notes (mentions des blockers)~~ (supprimé)
|
||||
|
||||
## 📊 Phase 5.6: Résumé hebdomadaire pour Individual Review (EN COURS)
|
||||
|
||||
### 5.6.1 Fonctionnalités de base (TERMINÉ)
|
||||
- [x] Vue résumé des 7 derniers jours (daily items + tâches)
|
||||
- [x] Statistiques globales (completion rates, jour le plus productif)
|
||||
- [x] Timeline chronologique des activités
|
||||
- [x] Filtrage par jour de la semaine
|
||||
- [x] Architecture SSR pour performance optimale
|
||||
|
||||
### 5.6.2 Améliorations pour l'Individual Review Manager 🎯
|
||||
- [ ] **Métriques de performance personnelles**
|
||||
- [ ] Vélocité hebdomadaire (tasks completed/week)
|
||||
- [ ] Temps moyen de completion des tâches
|
||||
- [ ] Répartition par priorité (high/medium/low tasks)
|
||||
- [ ] Taux de respect des deadlines
|
||||
- [ ] Evolution des performances sur 4 semaines (tendance)
|
||||
|
||||
- [ ] **Catégorisation des activités professionnelles**
|
||||
- [ ] Auto-tagging par type : "Development", "Meetings", "Documentation", "Code Review"
|
||||
- [ ] Répartition temps par catégorie (% dev vs meetings vs admin)
|
||||
- [ ] Identification des "deep work" sessions vs interruptions
|
||||
- [ ] Tracking des objectifs OKRs/KPIs assignés
|
||||
|
||||
- [ ] **Visualisations pour manager**
|
||||
- [ ] Graphique en aires : progression hebdomadaire
|
||||
- [ ] Heatmap de productivité : heures/jours les plus productifs
|
||||
- [ ] Radar chart : compétences/domaines travaillés
|
||||
- [ ] Burndown chart personnel : objectifs vs réalisé
|
||||
|
||||
- [ ] **Rapport automatique formaté**
|
||||
- [ ] Export PDF professionnel avec métriques
|
||||
- [ ] Template "Weekly Accomplishments" pré-rempli
|
||||
- [ ] Bullet points des principales réalisations
|
||||
- [ ] Section "Challenges & Blockers" automatique
|
||||
- [ ] Recommandations d'amélioration basées sur les patterns
|
||||
|
||||
- [ ] **Contexte business et impact**
|
||||
- [ ] Liaison tâches → tickets Jira → business value
|
||||
- [ ] Calcul d'impact estimé (story points, business priority)
|
||||
- [ ] Suivi des initiatives stratégiques
|
||||
- [ ] Corrélation avec les métriques d'équipe
|
||||
|
||||
- [ ] **Intelligence et insights**
|
||||
- [ ] Détection patterns de productivité personnels
|
||||
- [ ] Suggestions d'optimisation du planning
|
||||
- [ ] Alertes sur la charge de travail excessive
|
||||
- [ ] Comparaison avec moyennes d'équipe (anonyme)
|
||||
- [ ] Prédiction de capacity pour la semaine suivante
|
||||
|
||||
- [ ] **Fonctionnalités avancées pour 1-on-1**
|
||||
- [ ] Mode "Manager View" : vue consolidée pour discussions
|
||||
- [ ] Annotations et notes privées sur les réalisations
|
||||
- [ ] Objectifs SMART tracking avec progress bars
|
||||
- [ ] Archivage des reviews précédentes pour suivi long terme
|
||||
- [ ] Templates de questions pour auto-reflection
|
||||
|
||||
### 5.6.3 Intégrations externes pour contexte pro
|
||||
- [ ] **Import calendrier** : Meetings duration & frequency
|
||||
- [ ] **GitHub/GitLab integration** : Commits, PRs, code reviews
|
||||
- [ ] **Slack integration** : Messages envoyés, réactions, temps de réponse
|
||||
- [ ] **Confluence/Notion** : Documents créés/édités
|
||||
- [ ] **Time tracking tools** : Import depuis Toggl, Clockify, etc.
|
||||
|
||||
### 5.6.4 Machine Learning & Predictions
|
||||
- [ ] **Modèle de productivité personnelle**
|
||||
- [ ] Prédiction des jours de forte/faible productivité
|
||||
- [ ] Recommandations de planning optimal
|
||||
- [ ] Détection automatique de burnout patterns
|
||||
- [ ] Suggestions de breaks et équilibre work-life
|
||||
|
||||
- [ ] **Insights business automatiques**
|
||||
- [ ] "Cette semaine, tu as contribué à 3 initiatives stratégiques"
|
||||
- [ ] "Ton focus sur la qualité (code reviews) est 20% au-dessus de la moyenne"
|
||||
- [ ] "Suggestion: bloquer 2h demain pour deep work sur Project X"
|
||||
|
||||
### 🚀 Quick Wins pour démarrer (Priorité 1) ✅ TERMINÉ
|
||||
- [x] **Métriques de vélocité personnelle** (1-2h)
|
||||
- [x] Calcul tâches complétées par jour/semaine
|
||||
- [x] Graphique simple ligne de tendance sur 4 semaines
|
||||
- [x] Comparaison semaine actuelle vs semaine précédente
|
||||
|
||||
- [x] **Export PDF basique** (2-3h)
|
||||
- [x] Génération PDF simple avec statistiques actuelles
|
||||
- [x] Template "Weekly Summary" avec logo/header pro
|
||||
- [x] Liste des principales réalisations de la semaine
|
||||
|
||||
- [x] **Catégorisation simple par tags** (1h)
|
||||
- [x] Tags prédéfinis : "Dev", "Meeting", "Admin", "Learning"
|
||||
- [x] Auto-suggestion basée sur mots-clés dans les titres
|
||||
- [x] Répartition en camembert par catégorie
|
||||
|
||||
- [x] **Connexion Jira pour contexte business** ~~(supprimé par demande utilisateur)~~
|
||||
- ~~[x] Affichage des story points complétés~~
|
||||
- ~~[x] Lien vers les tickets Jira depuis les tâches~~
|
||||
- ~~[x] Récap des sprints/epics contributés~~
|
||||
|
||||
- [x] **Période flexible** (1h)
|
||||
- [x] Sélecteur de période : dernière semaine, 2 semaines, mois
|
||||
- [x] Comparaison période courante vs période précédente
|
||||
- [x] Sauvegarde de la période préférée
|
||||
|
||||
### 💡 Idées spécifiques pour Individual Review
|
||||
|
||||
#### **Sections du rapport idéal :**
|
||||
1. **Executive Summary** (3-4 bullet points impact business)
|
||||
2. **Quantified Achievements** (metrics, numbers, scope)
|
||||
3. **Technical Contributions** (code, architecture, tools)
|
||||
4. **Collaboration Impact** (reviews, mentoring, knowledge sharing)
|
||||
5. **Process Improvements** (efficiency gains, automation)
|
||||
6. **Learning & Growth** (new skills, certifications, initiatives)
|
||||
7. **Challenges & Solutions** (blockers overcome, lessons learned)
|
||||
8. **Next Period Goals** (SMART objectives, capacity planning)
|
||||
|
||||
#### **Métriques qui impressionnent un manager :**
|
||||
- **Velocity & Consistency** : "Completed 23 tasks with 94% on-time delivery"
|
||||
- **Quality Focus** : "15 code reviews provided, 0 production bugs"
|
||||
- **Initiative** : "Automated deployment reducing release time by 30%"
|
||||
- **Business Impact** : "Features delivered serve 10K+ users daily"
|
||||
- **Collaboration** : "Mentored 2 junior devs, led 3 technical sessions"
|
||||
- **Efficiency** : "Process optimization saved team 5h/week"
|
||||
|
||||
#### **Questions auto-reflection intégrées :**
|
||||
- "What was your biggest technical achievement this week?"
|
||||
- "Which tasks had the highest business impact?"
|
||||
- "What blockers did you encounter and how did you solve them?"
|
||||
- "What did you learn that you can share with the team?"
|
||||
- "What would you do differently next week?"
|
||||
|
||||
## Autre Todos #2
|
||||
- [ ] Synchro Jira auto en background timé comme pour la synchro de sauvegarde
|
||||
- [ ] refacto des allpreferences : ca devrait eter un contexte dans le layout qui balance serverside dans le hook
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
'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 (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="text-lg font-semibold">📊 Sélection de période</h3>
|
||||
<div className="flex gap-2">
|
||||
{PERIOD_OPTIONS.map((option) => (
|
||||
<Button
|
||||
key={option.key}
|
||||
onClick={() => onPeriodChange(option)}
|
||||
variant={currentPeriod.key === option.key ? "primary" : "secondary"}
|
||||
size="sm"
|
||||
disabled={isLoading}
|
||||
>
|
||||
{option.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
{comparison && (
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
{/* Titre de comparaison */}
|
||||
<h4 className="font-medium">
|
||||
Comparaison avec la période précédente
|
||||
</h4>
|
||||
|
||||
{/* Métriques de comparaison */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
{/* Tâches */}
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--primary)]/50 transition-colors">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-sm font-medium text-[var(--primary)]">Tâches complétées</span>
|
||||
<span className={`text-sm font-medium ${getChangeColor(comparison.changes.tasks)}`}>
|
||||
{getChangeIcon(comparison.changes.tasks)} {formatChange(comparison.changes.tasks)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-[var(--foreground)] font-medium">
|
||||
Actuelle: {comparison.currentPeriod.tasks}
|
||||
</span>
|
||||
<span className="text-[var(--muted-foreground)]">
|
||||
Précédente: {comparison.previousPeriod.tasks}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Daily items */}
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--success)]/50 transition-colors">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-sm font-medium text-[var(--success)]">Daily items</span>
|
||||
<span className={`text-sm font-medium ${getChangeColor(comparison.changes.checkboxes)}`}>
|
||||
{getChangeIcon(comparison.changes.checkboxes)} {formatChange(comparison.changes.checkboxes)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-[var(--foreground)] font-medium">
|
||||
Actuelle: {comparison.currentPeriod.checkboxes}
|
||||
</span>
|
||||
<span className="text-[var(--muted-foreground)]">
|
||||
Précédente: {comparison.previousPeriod.checkboxes}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Total */}
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--accent)]/50 transition-colors">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-sm font-medium text-[var(--accent)]">Total activités</span>
|
||||
<span className={`text-sm font-medium ${getChangeColor(comparison.changes.total)}`}>
|
||||
{getChangeIcon(comparison.changes.total)} {formatChange(comparison.changes.total)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="text-[var(--foreground)] font-medium">
|
||||
Actuelle: {comparison.currentPeriod.total}
|
||||
</span>
|
||||
<span className="text-[var(--muted-foreground)]">
|
||||
Précédente: {comparison.previousPeriod.total}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Insights sur la comparaison */}
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)]">
|
||||
<h5 className="font-medium mb-2">💡 Insights comparatifs</h5>
|
||||
<div className="text-sm text-[var(--muted-foreground)] space-y-1">
|
||||
{comparison.changes.total > 15 && (
|
||||
<p>🚀 Excellente progression ! Productivité en hausse de {formatChange(comparison.changes.total)}.</p>
|
||||
)}
|
||||
{comparison.changes.total < -15 && (
|
||||
<p>📉 Baisse d'activité de {formatChange(Math.abs(comparison.changes.total))}. Période moins chargée ?</p>
|
||||
)}
|
||||
{Math.abs(comparison.changes.total) <= 15 && (
|
||||
<p>✅ Rythme stable maintenu entre les deux périodes.</p>
|
||||
)}
|
||||
|
||||
{comparison.changes.tasks > comparison.changes.checkboxes + 10 && (
|
||||
<p>🎯 Focus accru sur les tâches importantes cette période.</p>
|
||||
)}
|
||||
{comparison.changes.checkboxes > comparison.changes.tasks + 10 && (
|
||||
<p>📝 Activité quotidienne plus intense cette période.</p>
|
||||
)}
|
||||
|
||||
<p>
|
||||
📊 Évolution globale: {comparison.currentPeriod.total} activités vs {comparison.previousPeriod.total} la période précédente.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
'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 (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-lg font-semibold">⚡ Métriques de vélocité</h3>
|
||||
<p className="text-sm text-[var(--muted-foreground)]">
|
||||
Performance sur les 4 dernières semaines
|
||||
</p>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent className="space-y-6">
|
||||
{/* Métriques principales */}
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--primary)]/50 transition-colors text-center">
|
||||
<div className="text-2xl font-bold text-[var(--primary)]">
|
||||
{velocity.currentWeekTasks}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Tâches cette semaine</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--muted-foreground)]/50 transition-colors text-center">
|
||||
<div className="text-2xl font-bold text-[var(--muted-foreground)]">
|
||||
{velocity.previousWeekTasks}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Semaine précédente</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--accent)]/50 transition-colors text-center">
|
||||
<div className="text-2xl font-bold text-[var(--accent)]">
|
||||
{velocity.fourWeekAverage.toFixed(1)}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Moyenne 4 semaines</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--success)]/50 transition-colors text-center">
|
||||
<div className={`text-2xl font-bold ${getTrendColor(velocity.weeklyTrend)}`}>
|
||||
{getTrendIcon(velocity.weeklyTrend)} {formatTrend(velocity.weeklyTrend)}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Tendance</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Graphique de tendance simple */}
|
||||
<div>
|
||||
<h4 className="font-medium mb-3">📊 Tendance sur 4 semaines</h4>
|
||||
<div className="grid grid-cols-4 gap-2">
|
||||
{velocity.weeklyData.map((week, index) => {
|
||||
const height = maxActivities > 0 ? (week.totalActivities / maxActivities) * 100 : 0;
|
||||
const weekLabel = `S${index + 1}`;
|
||||
|
||||
return (
|
||||
<div key={index} className="text-center">
|
||||
<div className="h-24 flex items-end justify-center mb-2">
|
||||
<div
|
||||
className="bg-[var(--primary)] w-8 rounded-t transition-all hover:bg-[var(--primary)]/80"
|
||||
style={{ height: `${Math.max(height, 5)}%` }}
|
||||
title={`${week.totalActivities} activités complétées`}
|
||||
/>
|
||||
</div>
|
||||
<div className="text-xs font-medium">{weekLabel}</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
{week.totalActivities}
|
||||
</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
{new Date(week.weekStart).toLocaleDateString('fr-FR', {
|
||||
day: 'numeric',
|
||||
month: 'short'
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Détails par semaine */}
|
||||
<div>
|
||||
<h4 className="font-medium mb-3">📈 Détails par semaine</h4>
|
||||
<div className="space-y-2">
|
||||
{velocity.weeklyData.map((week, index) => {
|
||||
const isCurrentWeek = index === velocity.weeklyData.length - 1;
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className={`flex items-center justify-between p-3 rounded-lg border transition-colors ${
|
||||
isCurrentWeek ? 'bg-[var(--primary)]/10 border-[var(--primary)]/30' : 'bg-[var(--card)] border-[var(--border)] hover:border-[var(--border)]/80'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-sm font-medium">
|
||||
Semaine du {new Date(week.weekStart).toLocaleDateString('fr-FR', {
|
||||
day: 'numeric',
|
||||
month: 'short'
|
||||
})}
|
||||
</span>
|
||||
{isCurrentWeek && (
|
||||
<Badge className="bg-[var(--primary)]/20 text-[var(--primary)]">Actuelle</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-4 text-sm">
|
||||
<span className="text-[var(--success)]">
|
||||
{week.completedTasks} tâches
|
||||
</span>
|
||||
<span className="text-[var(--primary)]">
|
||||
{week.completedCheckboxes} daily
|
||||
</span>
|
||||
<span className="font-medium text-[var(--foreground)]">
|
||||
Total: {week.totalActivities}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Insights */}
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)]">
|
||||
<h4 className="font-medium mb-2">💡 Insights</h4>
|
||||
<div className="text-sm text-[var(--muted-foreground)] space-y-1">
|
||||
{velocity.weeklyTrend > 10 && (
|
||||
<p>🚀 Excellente progression ! Vous êtes {velocity.weeklyTrend.toFixed(1)}% plus productif cette semaine.</p>
|
||||
)}
|
||||
{velocity.weeklyTrend < -10 && (
|
||||
<p>⚠️ Baisse d'activité de {Math.abs(velocity.weeklyTrend).toFixed(1)}%. Peut-être temps de revoir votre planning ?</p>
|
||||
)}
|
||||
{Math.abs(velocity.weeklyTrend) <= 10 && (
|
||||
<p>✅ Rythme stable. Vous maintenez une productivité constante.</p>
|
||||
)}
|
||||
<p>
|
||||
📊 Votre moyenne sur 4 semaines est de {velocity.fourWeekAverage.toFixed(1)} activités par semaine.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,448 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { WeeklySummary, WeeklyActivity, PERIOD_OPTIONS, PeriodOption } from '@/services/weekly-summary';
|
||||
import { Card, CardHeader, CardContent } from '@/components/ui/Card';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import { VelocityMetrics } from './VelocityMetrics';
|
||||
import { CategoryBreakdown } from './CategoryBreakdown';
|
||||
import { PeriodSelector } from './PeriodSelector';
|
||||
import { PDFExportService } from '@/services/pdf-export';
|
||||
|
||||
interface WeeklySummaryClientProps {
|
||||
initialSummary: WeeklySummary;
|
||||
}
|
||||
|
||||
export default function WeeklySummaryClient({ initialSummary }: WeeklySummaryClientProps) {
|
||||
const [summary, setSummary] = useState<WeeklySummary>(initialSummary);
|
||||
const [selectedDay, setSelectedDay] = useState<string | null>(null);
|
||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||
const [isExportingPDF, setIsExportingPDF] = useState(false);
|
||||
const [currentPeriod, setCurrentPeriod] = useState<PeriodOption>(PERIOD_OPTIONS[0]);
|
||||
const [activeTab, setActiveTab] = useState<string>('all');
|
||||
|
||||
const handlePeriodChange = async (newPeriod: PeriodOption) => {
|
||||
setCurrentPeriod(newPeriod);
|
||||
setIsRefreshing(true);
|
||||
|
||||
try {
|
||||
// Appel API pour récupérer les données de la nouvelle période
|
||||
const response = await fetch(`/api/weekly-summary?period=${newPeriod.days}`);
|
||||
if (response.ok) {
|
||||
const newSummary = await response.json();
|
||||
setSummary(newSummary);
|
||||
} else {
|
||||
console.error('Erreur lors du changement de période');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du changement de période:', error);
|
||||
} finally {
|
||||
setIsRefreshing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setIsRefreshing(true);
|
||||
// Recharger la page pour refaire le fetch côté serveur
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const handleExportPDF = async () => {
|
||||
setIsExportingPDF(true);
|
||||
try {
|
||||
await PDFExportService.exportWeeklySummary(summary);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de l\'export PDF:', error);
|
||||
alert('Erreur lors de la génération du PDF');
|
||||
} finally {
|
||||
setIsExportingPDF(false);
|
||||
}
|
||||
};
|
||||
|
||||
const formatDate = (date: Date) => {
|
||||
return new Date(date).toLocaleDateString('fr-FR', {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long'
|
||||
});
|
||||
};
|
||||
|
||||
const getActivityIcon = (activity: WeeklyActivity) => {
|
||||
if (activity.type === 'checkbox') {
|
||||
return activity.completed ? '✅' : '☐';
|
||||
}
|
||||
return activity.completed ? '🎯' : '📝';
|
||||
};
|
||||
|
||||
const getActivityTypeLabel = (type: 'checkbox' | 'task') => {
|
||||
return type === 'checkbox' ? 'Daily' : 'Tâche';
|
||||
};
|
||||
|
||||
// Obtenir les catégories disponibles
|
||||
const availableCategories = Object.keys(summary.categoryBreakdown).filter(
|
||||
categoryName => summary.categoryBreakdown[categoryName].count > 0
|
||||
);
|
||||
|
||||
// Fonction pour catégoriser une activité
|
||||
const getActivityCategory = (activity: WeeklyActivity): string => {
|
||||
// Logique simple pour associer une activité à une catégorie
|
||||
// En production, cette logique devrait être dans un service
|
||||
const title = activity.title.toLowerCase();
|
||||
|
||||
if (title.includes('meeting') || title.includes('réunion') || title.includes('call') || title.includes('standup')) {
|
||||
return 'Meeting';
|
||||
}
|
||||
if (title.includes('dev') || title.includes('code') || title.includes('bug') || title.includes('fix') || title.includes('feature')) {
|
||||
return 'Dev';
|
||||
}
|
||||
if (title.includes('admin') || title.includes('email') || title.includes('report') || title.includes('planning')) {
|
||||
return 'Admin';
|
||||
}
|
||||
if (title.includes('learn') || title.includes('study') || title.includes('formation') || title.includes('tutorial')) {
|
||||
return 'Learning';
|
||||
}
|
||||
return 'Other';
|
||||
};
|
||||
|
||||
// Filtrer les activités
|
||||
let filteredActivities = selectedDay
|
||||
? summary.activities.filter(a => a.dayName === selectedDay)
|
||||
: summary.activities;
|
||||
|
||||
// Filtrer par catégorie si ce n'est pas "all"
|
||||
if (activeTab !== 'all') {
|
||||
filteredActivities = filteredActivities.filter(activity =>
|
||||
getActivityCategory(activity) === activeTab
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Sélecteur de période */}
|
||||
<PeriodSelector
|
||||
currentPeriod={currentPeriod}
|
||||
onPeriodChange={handlePeriodChange}
|
||||
comparison={summary.periodComparison}
|
||||
isLoading={isRefreshing}
|
||||
/>
|
||||
|
||||
{/* Métriques de vélocité */}
|
||||
<VelocityMetrics velocity={summary.velocity} />
|
||||
|
||||
{/* Onglets par catégorie */}
|
||||
<div className="border-b border-[var(--border)]">
|
||||
<nav className="flex space-x-8 overflow-x-auto">
|
||||
<button
|
||||
onClick={() => setActiveTab('all')}
|
||||
className={`py-3 px-1 border-b-2 font-medium text-sm transition-colors whitespace-nowrap ${
|
||||
activeTab === 'all'
|
||||
? 'border-[var(--primary)] text-[var(--primary)]'
|
||||
: 'border-transparent text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:border-[var(--border)]'
|
||||
}`}
|
||||
>
|
||||
📊 Vue d'ensemble
|
||||
</button>
|
||||
{availableCategories.map(categoryName => {
|
||||
const categoryData = summary.categoryBreakdown[categoryName];
|
||||
return (
|
||||
<button
|
||||
key={categoryName}
|
||||
onClick={() => setActiveTab(categoryName)}
|
||||
className={`py-3 px-1 border-b-2 font-medium text-sm transition-colors whitespace-nowrap flex items-center gap-2 ${
|
||||
activeTab === categoryName
|
||||
? 'border-[var(--primary)] text-[var(--primary)]'
|
||||
: 'border-transparent text-[var(--muted-foreground)] hover:text-[var(--foreground)] hover:border-[var(--border)]'
|
||||
}`}
|
||||
>
|
||||
<span>{categoryData.icon}</span>
|
||||
<span>{categoryName}</span>
|
||||
<Badge className="bg-[var(--primary)]/10 text-[var(--primary)] text-xs">
|
||||
{categoryData.count}
|
||||
</Badge>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
{/* Contenu de l'onglet sélectionné */}
|
||||
{activeTab === 'all' && (
|
||||
<>
|
||||
{/* Répartition par catégorie */}
|
||||
<CategoryBreakdown
|
||||
categoryData={summary.categoryBreakdown}
|
||||
totalActivities={summary.stats.totalTasks + summary.stats.totalCheckboxes}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Vue spécifique par catégorie */}
|
||||
{activeTab !== 'all' && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-2xl">{summary.categoryBreakdown[activeTab]?.icon}</span>
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">{activeTab}</h2>
|
||||
<p className="text-sm text-[var(--muted-foreground)]">
|
||||
{summary.categoryBreakdown[activeTab]?.count} activités
|
||||
({summary.categoryBreakdown[activeTab]?.percentage.toFixed(1)}% de votre temps)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{/* Métriques spécifiques à la catégorie */}
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] text-center">
|
||||
<div className="text-2xl font-bold text-[var(--primary)]">
|
||||
{filteredActivities.length}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Total activités</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] text-center">
|
||||
<div className="text-2xl font-bold text-[var(--success)]">
|
||||
{filteredActivities.filter(a => a.completed).length}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Complétées</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] text-center">
|
||||
<div className="text-2xl font-bold text-[var(--accent)]">
|
||||
{filteredActivities.length > 0
|
||||
? Math.round((filteredActivities.filter(a => a.completed).length / filteredActivities.length) * 100)
|
||||
: 0}%
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Taux completion</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] text-center">
|
||||
<div className="text-2xl font-bold" style={{ color: summary.categoryBreakdown[activeTab]?.color }}>
|
||||
{summary.categoryBreakdown[activeTab]?.percentage.toFixed(1)}%
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Du temps total</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Contenu commun à tous les onglets */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">
|
||||
{activeTab === 'all' ? '📅 Résumé de la semaine' : `${summary.categoryBreakdown[activeTab]?.icon} Activités ${activeTab}`}
|
||||
</h2>
|
||||
<p className="text-sm text-[var(--muted-foreground)]">
|
||||
Du {formatDate(summary.period.start)} au {formatDate(summary.period.end)}
|
||||
{activeTab !== 'all' && ` • ${filteredActivities.length} activités`}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={handleExportPDF}
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
disabled={isExportingPDF}
|
||||
>
|
||||
{isExportingPDF ? '📄' : '📄'} {isExportingPDF ? 'Génération...' : 'Export PDF'}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleRefresh}
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
disabled={isRefreshing}
|
||||
>
|
||||
{isRefreshing ? '🔄' : '🔄'} {isRefreshing ? 'Actualisation...' : 'Actualiser'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent className="space-y-6">
|
||||
{/* Statistiques globales ou spécifiques à la catégorie */}
|
||||
{activeTab === 'all' ? (
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div className="bg-blue-50 rounded-lg p-4 text-center">
|
||||
<div className="text-2xl font-bold text-blue-600">
|
||||
{summary.stats.completedCheckboxes}
|
||||
</div>
|
||||
<div className="text-sm text-blue-600">Daily items</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
sur {summary.stats.totalCheckboxes} ({summary.stats.checkboxCompletionRate.toFixed(0)}%)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-green-50 rounded-lg p-4 text-center">
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{summary.stats.completedTasks}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">Tâches</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
sur {summary.stats.totalTasks} ({summary.stats.taskCompletionRate.toFixed(0)}%)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-purple-50 rounded-lg p-4 text-center">
|
||||
<div className="text-2xl font-bold text-purple-600">
|
||||
{summary.stats.completedCheckboxes + summary.stats.completedTasks}
|
||||
</div>
|
||||
<div className="text-sm text-purple-600">Total complété</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
sur {summary.stats.totalCheckboxes + summary.stats.totalTasks}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-orange-50 rounded-lg p-4 text-center">
|
||||
<div className="text-lg font-bold text-orange-600">
|
||||
{summary.stats.mostProductiveDay}
|
||||
</div>
|
||||
<div className="text-sm text-orange-600">Jour le plus productif</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div className="bg-blue-50 rounded-lg p-4 text-center">
|
||||
<div className="text-2xl font-bold text-blue-600">
|
||||
{filteredActivities.length}
|
||||
</div>
|
||||
<div className="text-sm text-blue-600">Activités {activeTab}</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-green-50 rounded-lg p-4 text-center">
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{filteredActivities.filter(a => a.completed).length}
|
||||
</div>
|
||||
<div className="text-sm text-green-600">Complétées</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-purple-50 rounded-lg p-4 text-center">
|
||||
<div className="text-2xl font-bold text-purple-600">
|
||||
{filteredActivities.length > 0
|
||||
? Math.round((filteredActivities.filter(a => a.completed).length / filteredActivities.length) * 100)
|
||||
: 0}%
|
||||
</div>
|
||||
<div className="text-sm text-purple-600">Taux de réussite</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-orange-50 rounded-lg p-4 text-center">
|
||||
<div className="text-2xl font-bold text-orange-600">
|
||||
{summary.categoryBreakdown[activeTab]?.percentage.toFixed(1)}%
|
||||
</div>
|
||||
<div className="text-sm text-orange-600">Du temps total</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Breakdown par jour */}
|
||||
<div>
|
||||
<h3 className="font-medium mb-3">
|
||||
📊 Répartition par jour
|
||||
{activeTab !== 'all' && <span className="text-sm font-normal text-[var(--muted-foreground)]"> - {activeTab}</span>}
|
||||
</h3>
|
||||
<div className="grid grid-cols-7 gap-2 mb-4">
|
||||
{summary.stats.dailyBreakdown.map((day) => {
|
||||
// Pour chaque jour, calculer les activités de la catégorie sélectionnée
|
||||
const dayActivitiesAll = summary.activities.filter(a => a.dayName === day.dayName);
|
||||
const dayActivitiesFiltered = activeTab === 'all'
|
||||
? dayActivitiesAll
|
||||
: dayActivitiesAll.filter(activity => getActivityCategory(activity) === activeTab);
|
||||
|
||||
const completedCount = dayActivitiesFiltered.filter(a => a.completed).length;
|
||||
const totalCount = dayActivitiesFiltered.length;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={day.date}
|
||||
onClick={() => setSelectedDay(selectedDay === day.dayName ? null : day.dayName)}
|
||||
className={`p-2 rounded-lg text-center transition-colors ${
|
||||
selectedDay === day.dayName
|
||||
? 'bg-blue-100 border-2 border-blue-300'
|
||||
: 'bg-[var(--muted)] hover:bg-[var(--muted)]/80'
|
||||
}`}
|
||||
>
|
||||
<div className="text-xs font-medium">
|
||||
{day.dayName.slice(0, 3)}
|
||||
</div>
|
||||
<div className="text-sm font-bold">
|
||||
{activeTab === 'all' ? (day.completedCheckboxes + day.completedTasks) : completedCount}
|
||||
</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
/{activeTab === 'all' ? (day.checkboxes + day.tasks) : totalCount}
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{selectedDay && (
|
||||
<div className="text-sm text-[var(--muted-foreground)] mb-4">
|
||||
📍 Filtré sur: <strong>{selectedDay}</strong>
|
||||
{activeTab !== 'all' && <span> • Catégorie: <strong>{activeTab}</strong></span>}
|
||||
<button
|
||||
onClick={() => setSelectedDay(null)}
|
||||
className="ml-2 text-blue-600 hover:underline"
|
||||
>
|
||||
(voir tout)
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Timeline des activités */}
|
||||
<div>
|
||||
<h3 className="font-medium mb-3">
|
||||
🕒 Timeline des activités {activeTab !== 'all' && `- ${activeTab}`}
|
||||
<span className="text-sm font-normal text-[var(--muted-foreground)]">
|
||||
({filteredActivities.length} items{activeTab !== 'all' && ` de la catégorie ${activeTab}`})
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
{filteredActivities.length === 0 ? (
|
||||
<div className="text-center py-8 text-[var(--muted-foreground)]">
|
||||
{selectedDay ? 'Aucune activité ce jour-là' : 'Aucune activité cette semaine'}
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2 max-h-96 overflow-y-auto">
|
||||
{filteredActivities.map((activity) => (
|
||||
<div
|
||||
key={activity.id}
|
||||
className={`flex items-center gap-3 p-3 rounded-lg border transition-colors ${
|
||||
activity.completed
|
||||
? 'bg-green-50 border-green-200'
|
||||
: 'bg-[var(--card)] border-[var(--border)]'
|
||||
}`}
|
||||
>
|
||||
<span className="text-lg flex-shrink-0">
|
||||
{getActivityIcon(activity)}
|
||||
</span>
|
||||
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className={`text-sm ${activity.completed ? 'line-through text-[var(--muted-foreground)]' : ''}`}>
|
||||
{activity.title}
|
||||
</span>
|
||||
<Badge className="text-xs bg-[var(--muted)] text-[var(--muted-foreground)]">
|
||||
{getActivityTypeLabel(activity.type)}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
{activity.dayName} • {new Date(activity.createdAt).toLocaleDateString('fr-FR')}
|
||||
{activity.completedAt && (
|
||||
<span> • Complété le {new Date(activity.completedAt).toLocaleDateString('fr-FR')}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -53,7 +53,6 @@ export function Header({ title = "TowerControl", subtitle = "Task Management", s
|
||||
{ href: '/', label: 'Dashboard' },
|
||||
{ href: '/kanban', label: 'Kanban' },
|
||||
{ href: '/daily', label: 'Daily' },
|
||||
{ href: '/weekly-summary', label: 'Hebdo' },
|
||||
{ href: '/weekly-manager', label: 'Manager' },
|
||||
...(isJiraConfigured ? [{ href: '/jira-dashboard', label: `Jira${jiraConfig?.projectKey ? ` (${jiraConfig.projectKey})` : ''}` }] : []),
|
||||
{ href: '/settings', label: 'Settings' }
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
import jsPDF from 'jspdf';
|
||||
import { WeeklySummary } from './weekly-summary';
|
||||
|
||||
export class PDFExportService {
|
||||
/**
|
||||
* Génère un PDF du résumé hebdomadaire
|
||||
*/
|
||||
static async exportWeeklySummary(summary: WeeklySummary): Promise<void> {
|
||||
const pdf = new jsPDF();
|
||||
const pageWidth = pdf.internal.pageSize.getWidth();
|
||||
const margin = 20;
|
||||
let yPosition = margin + 10;
|
||||
|
||||
// Header avec logo/titre
|
||||
pdf.setFontSize(24);
|
||||
pdf.setFont('helvetica', 'bold');
|
||||
pdf.text('📊 RÉSUMÉ HEBDOMADAIRE', pageWidth / 2, yPosition, { align: 'center' });
|
||||
|
||||
yPosition += 15;
|
||||
pdf.setFontSize(12);
|
||||
pdf.setFont('helvetica', 'normal');
|
||||
const dateRange = `Du ${this.formatDate(summary.period.start)} au ${this.formatDate(summary.period.end)}`;
|
||||
pdf.text(dateRange, pageWidth / 2, yPosition, { align: 'center' });
|
||||
|
||||
yPosition += 20;
|
||||
|
||||
// Section métriques principales
|
||||
pdf.setFontSize(16);
|
||||
pdf.setFont('helvetica', 'bold');
|
||||
pdf.text('🎯 MÉTRIQUES PRINCIPALES', margin, yPosition);
|
||||
yPosition += 15;
|
||||
|
||||
pdf.setFontSize(11);
|
||||
pdf.setFont('helvetica', 'normal');
|
||||
|
||||
// Statistiques en deux colonnes
|
||||
const statsLeft = [
|
||||
`Tâches complétées: ${summary.stats.completedTasks}/${summary.stats.totalTasks}`,
|
||||
`Taux de réussite tâches: ${summary.stats.taskCompletionRate.toFixed(1)}%`,
|
||||
`Daily items complétés: ${summary.stats.completedCheckboxes}/${summary.stats.totalCheckboxes}`,
|
||||
`Taux de réussite daily: ${summary.stats.checkboxCompletionRate.toFixed(1)}%`
|
||||
];
|
||||
|
||||
const statsRight = [
|
||||
`Vélocité actuelle: ${summary.velocity.currentWeekTasks} tâches`,
|
||||
`Semaine précédente: ${summary.velocity.previousWeekTasks} tâches`,
|
||||
`Moyenne 4 semaines: ${summary.velocity.fourWeekAverage.toFixed(1)}`,
|
||||
`Tendance: ${this.formatTrend(summary.velocity.weeklyTrend)}`
|
||||
];
|
||||
|
||||
// Colonne gauche
|
||||
statsLeft.forEach((stat, index) => {
|
||||
pdf.text(`• ${stat}`, margin, yPosition + (index * 8));
|
||||
});
|
||||
|
||||
// Colonne droite
|
||||
statsRight.forEach((stat, index) => {
|
||||
pdf.text(`• ${stat}`, pageWidth / 2 + 10, yPosition + (index * 8));
|
||||
});
|
||||
|
||||
yPosition += 40;
|
||||
|
||||
// Section jour le plus productif
|
||||
pdf.setFontSize(14);
|
||||
pdf.setFont('helvetica', 'bold');
|
||||
pdf.text('⭐ INSIGHTS', margin, yPosition);
|
||||
yPosition += 12;
|
||||
|
||||
pdf.setFontSize(11);
|
||||
pdf.setFont('helvetica', 'normal');
|
||||
pdf.text(`• Jour le plus productif: ${summary.stats.mostProductiveDay}`, margin + 5, yPosition);
|
||||
yPosition += 8;
|
||||
|
||||
// Tendance insight
|
||||
let trendInsight = '';
|
||||
if (summary.velocity.weeklyTrend > 10) {
|
||||
trendInsight = `• Excellente progression ! Amélioration de ${summary.velocity.weeklyTrend.toFixed(1)}% cette semaine.`;
|
||||
} else if (summary.velocity.weeklyTrend < -10) {
|
||||
trendInsight = `• Baisse d'activité de ${Math.abs(summary.velocity.weeklyTrend).toFixed(1)}%. Temps de revoir le planning ?`;
|
||||
} else {
|
||||
trendInsight = '• Rythme stable maintenu cette semaine.';
|
||||
}
|
||||
pdf.text(trendInsight, margin + 5, yPosition);
|
||||
yPosition += 12;
|
||||
|
||||
// Section breakdown par jour
|
||||
pdf.setFontSize(14);
|
||||
pdf.setFont('helvetica', 'bold');
|
||||
pdf.text('📅 RÉPARTITION PAR JOUR', margin, yPosition);
|
||||
yPosition += 12;
|
||||
|
||||
pdf.setFontSize(10);
|
||||
pdf.setFont('helvetica', 'normal');
|
||||
|
||||
// Headers du tableau
|
||||
const colWidth = (pageWidth - 2 * margin) / 4;
|
||||
pdf.text('Jour', margin, yPosition);
|
||||
pdf.text('Tâches', margin + colWidth, yPosition);
|
||||
pdf.text('Daily Items', margin + 2 * colWidth, yPosition);
|
||||
pdf.text('Total', margin + 3 * colWidth, yPosition);
|
||||
yPosition += 8;
|
||||
|
||||
// Ligne de séparation
|
||||
pdf.line(margin, yPosition - 2, pageWidth - margin, yPosition - 2);
|
||||
|
||||
// Données du tableau
|
||||
summary.stats.dailyBreakdown.forEach((day) => {
|
||||
pdf.text(day.dayName, margin, yPosition);
|
||||
pdf.text(`${day.completedTasks}/${day.tasks}`, margin + colWidth, yPosition);
|
||||
pdf.text(`${day.completedCheckboxes}/${day.checkboxes}`, margin + 2 * colWidth, yPosition);
|
||||
pdf.text(`${day.completedTasks + day.completedCheckboxes}`, margin + 3 * colWidth, yPosition);
|
||||
yPosition += 6;
|
||||
});
|
||||
|
||||
yPosition += 10;
|
||||
|
||||
// Section principales réalisations
|
||||
pdf.setFontSize(14);
|
||||
pdf.setFont('helvetica', 'bold');
|
||||
pdf.text('✅ PRINCIPALES RÉALISATIONS', margin, yPosition);
|
||||
yPosition += 12;
|
||||
|
||||
pdf.setFontSize(10);
|
||||
pdf.setFont('helvetica', 'normal');
|
||||
|
||||
const completedActivities = summary.activities
|
||||
.filter(a => a.completed)
|
||||
.slice(0, 8); // Top 8 réalisations
|
||||
|
||||
if (completedActivities.length === 0) {
|
||||
pdf.text('Aucune réalisation complétée cette semaine.', margin + 5, yPosition);
|
||||
yPosition += 8;
|
||||
} else {
|
||||
completedActivities.forEach((activity) => {
|
||||
const truncatedTitle = activity.title.length > 60
|
||||
? activity.title.substring(0, 57) + '...'
|
||||
: activity.title;
|
||||
|
||||
const icon = activity.type === 'task' ? '🎯' : '✅';
|
||||
pdf.text(`${icon} ${truncatedTitle}`, margin + 5, yPosition);
|
||||
yPosition += 6;
|
||||
|
||||
// Nouvelle page si nécessaire
|
||||
if (yPosition > pdf.internal.pageSize.getHeight() - 30) {
|
||||
pdf.addPage();
|
||||
yPosition = margin + 10;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Footer
|
||||
const totalPages = pdf.internal.getNumberOfPages();
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
pdf.setPage(i);
|
||||
pdf.setFontSize(8);
|
||||
pdf.setFont('helvetica', 'normal');
|
||||
const footerText = `TowerControl - Généré le ${new Date().toLocaleDateString('fr-FR')} - Page ${i}/${totalPages}`;
|
||||
pdf.text(footerText, pageWidth / 2, pdf.internal.pageSize.getHeight() - 10, { align: 'center' });
|
||||
}
|
||||
|
||||
// Télécharger le PDF
|
||||
const fileName = `weekly-summary-${this.formatDateForFilename(summary.period.start)}_${this.formatDateForFilename(summary.period.end)}.pdf`;
|
||||
pdf.save(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate une date pour l'affichage
|
||||
*/
|
||||
private static formatDate(date: Date): string {
|
||||
return new Date(date).toLocaleDateString('fr-FR', {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate une date pour le nom de fichier
|
||||
*/
|
||||
private static formatDateForFilename(date: Date): string {
|
||||
return new Date(date).toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Formate le pourcentage de tendance
|
||||
*/
|
||||
private static formatTrend(trend: number): string {
|
||||
const sign = trend > 0 ? '+' : '';
|
||||
return `${sign}${trend.toFixed(1)}%`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,438 +0,0 @@
|
||||
import { prisma } from './database';
|
||||
import { Task, TaskStatus, TaskPriority, TaskSource } from '@/lib/types';
|
||||
import { TaskCategorizationService } from './task-categorization';
|
||||
|
||||
export interface DailyItem {
|
||||
id: string;
|
||||
text: string;
|
||||
isChecked: boolean;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
date: Date;
|
||||
}
|
||||
|
||||
export interface WeeklyStats {
|
||||
totalCheckboxes: number;
|
||||
completedCheckboxes: number;
|
||||
totalTasks: number;
|
||||
completedTasks: number;
|
||||
checkboxCompletionRate: number;
|
||||
taskCompletionRate: number;
|
||||
mostProductiveDay: string;
|
||||
dailyBreakdown: Array<{
|
||||
date: string;
|
||||
dayName: string;
|
||||
checkboxes: number;
|
||||
completedCheckboxes: number;
|
||||
tasks: number;
|
||||
completedTasks: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface WeeklyActivity {
|
||||
id: string;
|
||||
type: 'checkbox' | 'task';
|
||||
title: string;
|
||||
completed: boolean;
|
||||
completedAt?: Date;
|
||||
createdAt: Date;
|
||||
date: string;
|
||||
dayName: string;
|
||||
}
|
||||
|
||||
export interface VelocityMetrics {
|
||||
currentWeekTasks: number;
|
||||
previousWeekTasks: number;
|
||||
weeklyTrend: number; // Pourcentage d'amélioration/détérioration
|
||||
fourWeekAverage: number;
|
||||
weeklyData: Array<{
|
||||
weekStart: Date;
|
||||
weekEnd: Date;
|
||||
completedTasks: number;
|
||||
completedCheckboxes: number;
|
||||
totalActivities: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface PeriodComparison {
|
||||
currentPeriod: {
|
||||
tasks: number;
|
||||
checkboxes: number;
|
||||
total: number;
|
||||
};
|
||||
previousPeriod: {
|
||||
tasks: number;
|
||||
checkboxes: number;
|
||||
total: number;
|
||||
};
|
||||
changes: {
|
||||
tasks: number; // pourcentage de changement
|
||||
checkboxes: number;
|
||||
total: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface WeeklySummary {
|
||||
stats: WeeklyStats;
|
||||
activities: WeeklyActivity[];
|
||||
velocity: VelocityMetrics;
|
||||
categoryBreakdown: { [categoryName: string]: { count: number; percentage: number; color: string; icon: string } };
|
||||
periodComparison: PeriodComparison | null;
|
||||
period: {
|
||||
start: Date;
|
||||
end: Date;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PeriodOption {
|
||||
label: string;
|
||||
days: number;
|
||||
key: string;
|
||||
}
|
||||
|
||||
export const PERIOD_OPTIONS: PeriodOption[] = [
|
||||
{ label: 'Dernière semaine', days: 7, key: 'week' },
|
||||
{ label: 'Dernières 2 semaines', days: 14, key: '2weeks' },
|
||||
{ label: 'Dernier mois', days: 30, key: 'month' }
|
||||
];
|
||||
|
||||
export class WeeklySummaryService {
|
||||
/**
|
||||
* Récupère le résumé complet de la semaine écoulée
|
||||
*/
|
||||
static async getWeeklySummary(periodDays: number = 7): Promise<WeeklySummary> {
|
||||
const now = new Date();
|
||||
const startOfPeriod = new Date(now);
|
||||
startOfPeriod.setDate(now.getDate() - periodDays);
|
||||
startOfPeriod.setHours(0, 0, 0, 0);
|
||||
|
||||
const endOfPeriod = new Date(now);
|
||||
endOfPeriod.setHours(23, 59, 59, 999);
|
||||
|
||||
console.log(`📊 Génération du résumé (${periodDays} jours) du ${startOfPeriod.toLocaleDateString()} au ${endOfPeriod.toLocaleDateString()}`);
|
||||
|
||||
const [checkboxes, tasks, velocity] = await Promise.all([
|
||||
this.getWeeklyCheckboxes(startOfPeriod, endOfPeriod),
|
||||
this.getWeeklyTasks(startOfPeriod, endOfPeriod),
|
||||
this.calculateVelocityMetrics(endOfPeriod)
|
||||
]);
|
||||
|
||||
const stats = this.calculateStats(checkboxes, tasks, startOfPeriod, endOfPeriod);
|
||||
const activities = this.mergeActivities(checkboxes, tasks);
|
||||
const categoryBreakdown = this.analyzeCategorization(checkboxes, tasks);
|
||||
|
||||
// Calculer la comparaison avec la période précédente
|
||||
const periodComparison = await this.calculatePeriodComparison(startOfPeriod, endOfPeriod, periodDays);
|
||||
|
||||
return {
|
||||
stats,
|
||||
activities,
|
||||
velocity,
|
||||
categoryBreakdown,
|
||||
periodComparison,
|
||||
period: {
|
||||
start: startOfPeriod,
|
||||
end: endOfPeriod
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les checkboxes des 7 derniers jours
|
||||
*/
|
||||
private static async getWeeklyCheckboxes(startDate: Date, endDate: Date): Promise<DailyItem[]> {
|
||||
const items = await prisma.dailyCheckbox.findMany({
|
||||
where: {
|
||||
date: {
|
||||
gte: startDate,
|
||||
lte: endDate
|
||||
}
|
||||
},
|
||||
orderBy: [
|
||||
{ date: 'desc' },
|
||||
{ createdAt: 'desc' }
|
||||
]
|
||||
});
|
||||
|
||||
return items.map(item => ({
|
||||
id: item.id,
|
||||
text: item.text,
|
||||
isChecked: item.isChecked,
|
||||
createdAt: item.createdAt,
|
||||
updatedAt: item.updatedAt,
|
||||
date: item.date
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les tâches des 7 derniers jours (créées ou modifiées)
|
||||
*/
|
||||
private static async getWeeklyTasks(startDate: Date, endDate: Date): Promise<Task[]> {
|
||||
const tasks = await prisma.task.findMany({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
createdAt: {
|
||||
gte: startDate,
|
||||
lte: endDate
|
||||
}
|
||||
},
|
||||
{
|
||||
updatedAt: {
|
||||
gte: startDate,
|
||||
lte: endDate
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
orderBy: {
|
||||
updatedAt: 'desc'
|
||||
}
|
||||
});
|
||||
|
||||
return tasks.map(task => ({
|
||||
id: task.id,
|
||||
title: task.title,
|
||||
description: task.description || '',
|
||||
status: task.status as TaskStatus,
|
||||
priority: task.priority as TaskPriority,
|
||||
source: task.source as TaskSource,
|
||||
sourceId: task.sourceId || undefined,
|
||||
createdAt: task.createdAt,
|
||||
updatedAt: task.updatedAt,
|
||||
dueDate: task.dueDate || undefined,
|
||||
completedAt: task.completedAt || undefined,
|
||||
jiraProject: task.jiraProject || undefined,
|
||||
jiraKey: task.jiraKey || undefined,
|
||||
jiraType: task.jiraType || undefined,
|
||||
assignee: task.assignee || undefined,
|
||||
tags: [] // Les tags sont dans une relation séparée, on les laisse vides pour l'instant
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcule les statistiques de la semaine
|
||||
*/
|
||||
private static calculateStats(
|
||||
checkboxes: DailyItem[],
|
||||
tasks: Task[],
|
||||
startDate: Date,
|
||||
endDate: Date
|
||||
): WeeklyStats {
|
||||
const completedCheckboxes = checkboxes.filter(c => c.isChecked);
|
||||
const completedTasks = tasks.filter(t => t.status === 'done');
|
||||
|
||||
// Créer un breakdown par jour
|
||||
const dailyBreakdown = [];
|
||||
const current = new Date(startDate);
|
||||
|
||||
while (current <= endDate) {
|
||||
const dayCheckboxes = checkboxes.filter(c =>
|
||||
c.date.toISOString().split('T')[0] === current.toISOString().split('T')[0]
|
||||
);
|
||||
const dayCompletedCheckboxes = dayCheckboxes.filter(c => c.isChecked);
|
||||
|
||||
// Pour les tâches, on compte celles modifiées ce jour-là
|
||||
const dayTasks = tasks.filter(t =>
|
||||
t.updatedAt.toISOString().split('T')[0] === current.toISOString().split('T')[0] ||
|
||||
t.createdAt.toISOString().split('T')[0] === current.toISOString().split('T')[0]
|
||||
);
|
||||
const dayCompletedTasks = dayTasks.filter(t => t.status === 'done');
|
||||
|
||||
dailyBreakdown.push({
|
||||
date: current.toISOString().split('T')[0],
|
||||
dayName: current.toLocaleDateString('fr-FR', { weekday: 'long' }),
|
||||
checkboxes: dayCheckboxes.length,
|
||||
completedCheckboxes: dayCompletedCheckboxes.length,
|
||||
tasks: dayTasks.length,
|
||||
completedTasks: dayCompletedTasks.length
|
||||
});
|
||||
|
||||
current.setDate(current.getDate() + 1);
|
||||
}
|
||||
|
||||
// Trouver le jour le plus productif
|
||||
const mostProductiveDay = dailyBreakdown.reduce((max, day) => {
|
||||
const dayScore = day.completedCheckboxes + day.completedTasks;
|
||||
const maxScore = max.completedCheckboxes + max.completedTasks;
|
||||
return dayScore > maxScore ? day : max;
|
||||
}, dailyBreakdown[0]);
|
||||
|
||||
return {
|
||||
totalCheckboxes: checkboxes.length,
|
||||
completedCheckboxes: completedCheckboxes.length,
|
||||
totalTasks: tasks.length,
|
||||
completedTasks: completedTasks.length,
|
||||
checkboxCompletionRate: checkboxes.length > 0 ? (completedCheckboxes.length / checkboxes.length) * 100 : 0,
|
||||
taskCompletionRate: tasks.length > 0 ? (completedTasks.length / tasks.length) * 100 : 0,
|
||||
mostProductiveDay: mostProductiveDay.dayName,
|
||||
dailyBreakdown
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcule les métriques de vélocité sur 4 semaines
|
||||
*/
|
||||
private static async calculateVelocityMetrics(currentEndDate: Date): Promise<VelocityMetrics> {
|
||||
const weeks = [];
|
||||
const currentDate = new Date(currentEndDate);
|
||||
|
||||
// Générer les 4 dernières semaines
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const weekEnd = new Date(currentDate);
|
||||
weekEnd.setDate(weekEnd.getDate() - (i * 7));
|
||||
weekEnd.setHours(23, 59, 59, 999);
|
||||
|
||||
const weekStart = new Date(weekEnd);
|
||||
weekStart.setDate(weekEnd.getDate() - 6);
|
||||
weekStart.setHours(0, 0, 0, 0);
|
||||
|
||||
const [weekCheckboxes, weekTasks] = await Promise.all([
|
||||
this.getWeeklyCheckboxes(weekStart, weekEnd),
|
||||
this.getWeeklyTasks(weekStart, weekEnd)
|
||||
]);
|
||||
|
||||
const completedTasks = weekTasks.filter(t => t.status === 'done').length;
|
||||
const completedCheckboxes = weekCheckboxes.filter(c => c.isChecked).length;
|
||||
|
||||
weeks.push({
|
||||
weekStart,
|
||||
weekEnd,
|
||||
completedTasks,
|
||||
completedCheckboxes,
|
||||
totalActivities: completedTasks + completedCheckboxes
|
||||
});
|
||||
}
|
||||
|
||||
// Calculer les métriques
|
||||
const currentWeek = weeks[0];
|
||||
const previousWeek = weeks[1];
|
||||
const fourWeekAverage = weeks.reduce((sum, week) => sum + week.totalActivities, 0) / weeks.length;
|
||||
|
||||
let weeklyTrend = 0;
|
||||
if (previousWeek.totalActivities > 0) {
|
||||
weeklyTrend = ((currentWeek.totalActivities - previousWeek.totalActivities) / previousWeek.totalActivities) * 100;
|
||||
} else if (currentWeek.totalActivities > 0) {
|
||||
weeklyTrend = 100; // 100% d'amélioration si on passe de 0 à quelque chose
|
||||
}
|
||||
|
||||
return {
|
||||
currentWeekTasks: currentWeek.completedTasks,
|
||||
previousWeekTasks: previousWeek.completedTasks,
|
||||
weeklyTrend,
|
||||
fourWeekAverage,
|
||||
weeklyData: weeks.reverse() // Plus ancien en premier pour l'affichage du graphique
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcule la comparaison avec la période précédente
|
||||
*/
|
||||
private static async calculatePeriodComparison(
|
||||
currentStart: Date,
|
||||
currentEnd: Date,
|
||||
periodDays: number
|
||||
): Promise<PeriodComparison> {
|
||||
// Période précédente
|
||||
const previousEnd = new Date(currentStart);
|
||||
previousEnd.setHours(23, 59, 59, 999);
|
||||
|
||||
const previousStart = new Date(previousEnd);
|
||||
previousStart.setDate(previousEnd.getDate() - periodDays);
|
||||
previousStart.setHours(0, 0, 0, 0);
|
||||
|
||||
const [currentCheckboxes, currentTasks, previousCheckboxes, previousTasks] = await Promise.all([
|
||||
this.getWeeklyCheckboxes(currentStart, currentEnd),
|
||||
this.getWeeklyTasks(currentStart, currentEnd),
|
||||
this.getWeeklyCheckboxes(previousStart, previousEnd),
|
||||
this.getWeeklyTasks(previousStart, previousEnd)
|
||||
]);
|
||||
|
||||
const currentCompletedTasks = currentTasks.filter(t => t.status === 'done').length;
|
||||
const currentCompletedCheckboxes = currentCheckboxes.filter(c => c.isChecked).length;
|
||||
const currentTotal = currentCompletedTasks + currentCompletedCheckboxes;
|
||||
|
||||
const previousCompletedTasks = previousTasks.filter(t => t.status === 'done').length;
|
||||
const previousCompletedCheckboxes = previousCheckboxes.filter(c => c.isChecked).length;
|
||||
const previousTotal = previousCompletedTasks + previousCompletedCheckboxes;
|
||||
|
||||
const calculateChange = (current: number, previous: number): number => {
|
||||
if (previous === 0) return current > 0 ? 100 : 0;
|
||||
return ((current - previous) / previous) * 100;
|
||||
};
|
||||
|
||||
return {
|
||||
currentPeriod: {
|
||||
tasks: currentCompletedTasks,
|
||||
checkboxes: currentCompletedCheckboxes,
|
||||
total: currentTotal
|
||||
},
|
||||
previousPeriod: {
|
||||
tasks: previousCompletedTasks,
|
||||
checkboxes: previousCompletedCheckboxes,
|
||||
total: previousTotal
|
||||
},
|
||||
changes: {
|
||||
tasks: calculateChange(currentCompletedTasks, previousCompletedTasks),
|
||||
checkboxes: calculateChange(currentCompletedCheckboxes, previousCompletedCheckboxes),
|
||||
total: calculateChange(currentTotal, previousTotal)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyse la catégorisation des activités
|
||||
*/
|
||||
private static analyzeCategorization(checkboxes: DailyItem[], tasks: Task[]): { [categoryName: string]: { count: number; percentage: number; color: string; icon: string } } {
|
||||
const allActivities = [
|
||||
...checkboxes.map(c => ({ title: c.text, description: '' })),
|
||||
...tasks.map(t => ({ title: t.title, description: t.description || '' }))
|
||||
];
|
||||
|
||||
return TaskCategorizationService.analyzeActivitiesByCategory(allActivities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fusionne les activités (checkboxes + tâches) en une timeline
|
||||
*/
|
||||
private static mergeActivities(checkboxes: DailyItem[], tasks: Task[]): WeeklyActivity[] {
|
||||
const activities: WeeklyActivity[] = [];
|
||||
|
||||
// Ajouter les checkboxes
|
||||
checkboxes.forEach(checkbox => {
|
||||
activities.push({
|
||||
id: `checkbox-${checkbox.id}`,
|
||||
type: 'checkbox',
|
||||
title: checkbox.text,
|
||||
completed: checkbox.isChecked,
|
||||
completedAt: checkbox.isChecked ? checkbox.updatedAt : undefined,
|
||||
createdAt: checkbox.createdAt,
|
||||
date: checkbox.date.toISOString().split('T')[0],
|
||||
dayName: checkbox.date.toLocaleDateString('fr-FR', { weekday: 'long' })
|
||||
});
|
||||
});
|
||||
|
||||
// Ajouter les tâches
|
||||
tasks.forEach(task => {
|
||||
const date = task.updatedAt.toISOString().split('T')[0];
|
||||
const dateObj = new Date(date + 'T00:00:00');
|
||||
activities.push({
|
||||
id: `task-${task.id}`,
|
||||
type: 'task',
|
||||
title: task.title,
|
||||
completed: task.status === 'done',
|
||||
completedAt: task.status === 'done' ? task.updatedAt : undefined,
|
||||
createdAt: task.createdAt,
|
||||
date: date,
|
||||
dayName: dateObj.toLocaleDateString('fr-FR', { weekday: 'long' })
|
||||
});
|
||||
});
|
||||
|
||||
// Trier par date (plus récent en premier)
|
||||
return activities.sort((a, b) => {
|
||||
const dateA = a.completedAt || a.createdAt;
|
||||
const dateB = b.completedAt || b.createdAt;
|
||||
return dateB.getTime() - dateA.getTime();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { WeeklySummaryService } from '@/services/weekly-summary';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const periodParam = searchParams.get('period');
|
||||
|
||||
// Valider le paramètre de période
|
||||
let periodDays = 7; // Défaut: 7 jours
|
||||
if (periodParam) {
|
||||
const parsedPeriod = parseInt(periodParam, 10);
|
||||
if (!isNaN(parsedPeriod) && parsedPeriod > 0 && parsedPeriod <= 365) {
|
||||
periodDays = parsedPeriod;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`📊 API weekly-summary appelée avec période: ${periodDays} jours`);
|
||||
|
||||
const summary = await WeeklySummaryService.getWeeklySummary(periodDays);
|
||||
|
||||
return NextResponse.json(summary, {
|
||||
headers: {
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||
'Pragma': 'no-cache',
|
||||
'Expires': '0'
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la génération du résumé hebdomadaire:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Erreur lors de la génération du résumé' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { Header } from '@/components/ui/Header';
|
||||
import WeeklySummaryClient from '@/components/dashboard/WeeklySummaryClient';
|
||||
import { WeeklySummaryService } from '@/services/weekly-summary';
|
||||
|
||||
export default async function WeeklySummaryPage() {
|
||||
// Récupération côté serveur
|
||||
const summary = await WeeklySummaryService.getWeeklySummary();
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[var(--background)]">
|
||||
<Header />
|
||||
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="max-w-6xl mx-auto">
|
||||
<WeeklySummaryClient initialSummary={summary} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user