feat: add weekly summary features and components
- Introduced `CategoryBreakdown`, `JiraWeeklyMetrics`, `PeriodSelector`, and `VelocityMetrics` components to enhance the weekly summary dashboard. - Updated `WeeklySummaryClient` to manage period selection and PDF export functionality. - Enhanced `WeeklySummaryService` to support period comparisons and activity categorization. - Added new API route for fetching weekly summary data based on selected period. - Updated `package.json` and `package-lock.json` to include `jspdf` and related types for PDF generation. - Marked several tasks as complete in `TODO.md` to reflect progress on summary features.
This commit is contained in:
42
TODO.md
42
TODO.md
@@ -380,31 +380,31 @@ Endpoints complexes → API Routes conservées
|
||||
- [ ] "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)
|
||||
- [ ] **Métriques de vélocité personnelle** (1-2h)
|
||||
- [ ] Calcul tâches complétées par jour/semaine
|
||||
- [ ] Graphique simple ligne de tendance sur 4 semaines
|
||||
- [ ] Comparaison semaine actuelle vs semaine précédente
|
||||
### 🚀 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
|
||||
|
||||
- [ ] **Export PDF basique** (2-3h)
|
||||
- [ ] Génération PDF simple avec statistiques actuelles
|
||||
- [ ] Template "Weekly Summary" avec logo/header pro
|
||||
- [ ] Liste des principales réalisations de la semaine
|
||||
- [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
|
||||
|
||||
- [ ] **Catégorisation simple par tags** (1h)
|
||||
- [ ] Tags prédéfinis : "Dev", "Meeting", "Admin", "Learning"
|
||||
- [ ] Auto-suggestion basée sur mots-clés dans les titres
|
||||
- [ ] Répartition en camembert par catégorie
|
||||
- [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
|
||||
|
||||
- [ ] **Connexion Jira pour contexte business** (3-4h)
|
||||
- [ ] Affichage des story points complétés
|
||||
- [ ] Lien vers les tickets Jira depuis les tâches
|
||||
- [ ] Récap des sprints/epics contributés
|
||||
- [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~~
|
||||
|
||||
- [ ] **Période flexible** (1h)
|
||||
- [ ] Sélecteur de période : dernière semaine, 2 semaines, mois
|
||||
- [ ] Comparaison période courante vs période précédente
|
||||
- [ ] Sauvegarde de la période préférée
|
||||
- [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
|
||||
|
||||
|
||||
146
components/dashboard/CategoryBreakdown.tsx
Normal file
146
components/dashboard/CategoryBreakdown.tsx
Normal file
@@ -0,0 +1,146 @@
|
||||
'use client';
|
||||
|
||||
import { Card, CardHeader, CardContent } from '@/components/ui/Card';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
|
||||
interface CategoryData {
|
||||
count: number;
|
||||
percentage: number;
|
||||
color: string;
|
||||
icon: string;
|
||||
}
|
||||
|
||||
interface CategoryBreakdownProps {
|
||||
categoryData: { [categoryName: string]: CategoryData };
|
||||
totalActivities: number;
|
||||
}
|
||||
|
||||
export function CategoryBreakdown({ categoryData, totalActivities }: CategoryBreakdownProps) {
|
||||
const categories = Object.entries(categoryData)
|
||||
.filter(([, data]) => data.count > 0)
|
||||
.sort((a, b) => b[1].count - a[1].count);
|
||||
|
||||
if (categories.length === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-lg font-semibold">📊 Répartition par catégorie</h3>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-center text-[var(--muted-foreground)]">
|
||||
Aucune activité à catégoriser
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-lg font-semibold">📊 Répartition par catégorie</h3>
|
||||
<p className="text-sm text-[var(--muted-foreground)]">
|
||||
Analyse automatique de vos {totalActivities} activités
|
||||
</p>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent className="space-y-6">
|
||||
{/* Légende des catégories */}
|
||||
<div className="flex flex-wrap gap-3 justify-center">
|
||||
{categories.map(([categoryName, data]) => (
|
||||
<div
|
||||
key={categoryName}
|
||||
className="flex items-center gap-2 bg-[var(--card)] border border-[var(--border)] rounded-lg px-3 py-2 hover:border-[var(--primary)]/50 transition-colors"
|
||||
>
|
||||
<div
|
||||
className="w-3 h-3 rounded-full"
|
||||
style={{ backgroundColor: data.color }}
|
||||
/>
|
||||
<span className="text-sm font-medium text-[var(--foreground)]">
|
||||
{data.icon} {categoryName}
|
||||
</span>
|
||||
<Badge className="bg-[var(--primary)]/10 text-[var(--primary)] text-xs">
|
||||
{data.count}
|
||||
</Badge>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Barres de progression */}
|
||||
<div className="space-y-3">
|
||||
{categories.map(([categoryName, data]) => (
|
||||
<div key={categoryName} className="space-y-1">
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<span className="flex items-center gap-2">
|
||||
<span>{data.icon}</span>
|
||||
<span className="font-medium">{categoryName}</span>
|
||||
</span>
|
||||
<span className="text-[var(--muted-foreground)]">
|
||||
{data.count} ({data.percentage.toFixed(1)}%)
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="w-full bg-[var(--border)] rounded-full h-2">
|
||||
<div
|
||||
className="h-2 rounded-full transition-all duration-500"
|
||||
style={{
|
||||
backgroundColor: data.color,
|
||||
width: `${data.percentage}%`
|
||||
}}
|
||||
/>
|
||||
</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">
|
||||
{categories.length > 0 && (
|
||||
<>
|
||||
<p>
|
||||
🏆 <strong>{categories[0][0]}</strong> est votre activité principale
|
||||
({categories[0][1].percentage.toFixed(1)}% de votre temps).
|
||||
</p>
|
||||
|
||||
{categories.length > 1 && (
|
||||
<p>
|
||||
📈 Vous avez une bonne diversité avec {categories.length} catégories d'activités.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Suggestions basées sur la répartition */}
|
||||
{categories.some(([, data]) => data.percentage > 70) && (
|
||||
<p>
|
||||
⚠️ Forte concentration sur une seule catégorie.
|
||||
Pensez à diversifier vos activités pour un meilleur équilibre.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{(() => {
|
||||
const learningCategory = categories.find(([name]) => name === 'Learning');
|
||||
return learningCategory && learningCategory[1].percentage > 0 && (
|
||||
<p>
|
||||
🎓 Excellent ! Vous consacrez du temps à l'apprentissage
|
||||
({learningCategory[1].percentage.toFixed(1)}%).
|
||||
</p>
|
||||
);
|
||||
})()}
|
||||
|
||||
{(() => {
|
||||
const devCategory = categories.find(([name]) => name === 'Dev');
|
||||
return devCategory && devCategory[1].percentage > 50 && (
|
||||
<p>
|
||||
💻 Focus développement intense. N'oubliez pas les pauses et la collaboration !
|
||||
</p>
|
||||
);
|
||||
})()}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
193
components/dashboard/JiraWeeklyMetrics.tsx
Normal file
193
components/dashboard/JiraWeeklyMetrics.tsx
Normal file
@@ -0,0 +1,193 @@
|
||||
'use client';
|
||||
|
||||
import type { JiraWeeklyMetrics } from '@/services/jira-summary';
|
||||
import { Card, CardHeader, CardContent } from '@/components/ui/Card';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import { JiraSummaryService } from '@/services/jira-summary';
|
||||
|
||||
interface JiraWeeklyMetricsProps {
|
||||
jiraMetrics: JiraWeeklyMetrics | null;
|
||||
}
|
||||
|
||||
export function JiraWeeklyMetrics({ jiraMetrics }: JiraWeeklyMetricsProps) {
|
||||
if (!jiraMetrics) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-lg font-semibold">🔗 Contexte business Jira</h3>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-center text-[var(--muted-foreground)]">
|
||||
Configuration Jira non disponible
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
if (jiraMetrics.totalJiraTasks === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-lg font-semibold">🔗 Contexte business Jira</h3>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-center text-[var(--muted-foreground)]">
|
||||
Aucune tâche Jira cette semaine
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
const completionRate = (jiraMetrics.completedJiraTasks / jiraMetrics.totalJiraTasks) * 100;
|
||||
const insights = JiraSummaryService.generateBusinessInsights(jiraMetrics);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<h3 className="text-lg font-semibold">🔗 Contexte business Jira</h3>
|
||||
<p className="text-sm text-[var(--muted-foreground)]">
|
||||
Impact business et métriques projet
|
||||
</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)]">
|
||||
{jiraMetrics.totalJiraTasks}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Tickets Jira</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 text-[var(--success)]">
|
||||
{completionRate.toFixed(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)] hover:border-[var(--accent)]/50 transition-colors text-center">
|
||||
<div className="text-2xl font-bold text-[var(--accent)]">
|
||||
{jiraMetrics.totalStoryPoints}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Story Points*</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)] hover:border-[var(--warning)]/50 transition-colors text-center">
|
||||
<div className="text-2xl font-bold text-[var(--warning)]">
|
||||
{jiraMetrics.projectsContributed.length}
|
||||
</div>
|
||||
<div className="text-sm text-[var(--muted-foreground)]">Projet(s)</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Projets contributés */}
|
||||
{jiraMetrics.projectsContributed.length > 0 && (
|
||||
<div>
|
||||
<h4 className="font-medium mb-2">📂 Projets contributés</h4>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{jiraMetrics.projectsContributed.map(project => (
|
||||
<Badge key={project} className="bg-[var(--primary)]/10 text-[var(--primary)]">
|
||||
{project}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Types de tickets */}
|
||||
<div>
|
||||
<h4 className="font-medium mb-3">🎯 Types de tickets</h4>
|
||||
<div className="space-y-2">
|
||||
{Object.entries(jiraMetrics.ticketTypes)
|
||||
.sort(([,a], [,b]) => b - a)
|
||||
.map(([type, count]) => {
|
||||
const percentage = (count / jiraMetrics.totalJiraTasks) * 100;
|
||||
return (
|
||||
<div key={type} className="flex items-center justify-between">
|
||||
<span className="text-sm text-[var(--foreground)]">{type}</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-20 bg-[var(--border)] rounded-full h-2">
|
||||
<div
|
||||
className="h-2 bg-[var(--primary)] rounded-full transition-all"
|
||||
style={{ width: `${percentage}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="text-sm text-[var(--muted-foreground)] w-8">
|
||||
{count}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Liens vers les tickets */}
|
||||
<div>
|
||||
<h4 className="font-medium mb-3">🎫 Tickets traités</h4>
|
||||
<div className="space-y-2 max-h-40 overflow-y-auto">
|
||||
{jiraMetrics.jiraLinks.map((link) => (
|
||||
<div
|
||||
key={link.key}
|
||||
className="flex items-center justify-between p-2 rounded border hover:bg-[var(--muted)] transition-colors"
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-[var(--primary)] hover:underline font-medium text-sm"
|
||||
>
|
||||
{link.key}
|
||||
</a>
|
||||
<Badge
|
||||
className={`text-xs ${
|
||||
link.status === 'done'
|
||||
? 'bg-[var(--success)]/10 text-[var(--success)]'
|
||||
: 'bg-[var(--muted)]/50 text-[var(--muted-foreground)]'
|
||||
}`}
|
||||
>
|
||||
{link.status}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="text-xs text-[var(--muted-foreground)] truncate">
|
||||
{link.title}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-xs text-[var(--muted-foreground)]">
|
||||
<span>{link.type}</span>
|
||||
<span>{link.estimatedPoints}pts</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Insights business */}
|
||||
{insights.length > 0 && (
|
||||
<div className="bg-[var(--card)] p-4 rounded-lg border border-[var(--border)]">
|
||||
<h4 className="font-medium mb-2">💡 Insights business</h4>
|
||||
<div className="text-sm text-[var(--muted-foreground)] space-y-1">
|
||||
{insights.map((insight, index) => (
|
||||
<p key={index}>{insight}</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Note sur les story points */}
|
||||
<div className="text-xs text-[var(--muted-foreground)] bg-[var(--card)] border border-[var(--border)] p-2 rounded">
|
||||
<p>
|
||||
* Story Points estimés automatiquement basés sur le type de ticket
|
||||
(Epic: 8pts, Story: 3pts, Task: 2pts, Bug: 1pt)
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
155
components/dashboard/PeriodSelector.tsx
Normal file
155
components/dashboard/PeriodSelector.tsx
Normal file
@@ -0,0 +1,155 @@
|
||||
'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>
|
||||
);
|
||||
}
|
||||
168
components/dashboard/VelocityMetrics.tsx
Normal file
168
components/dashboard/VelocityMetrics.tsx
Normal file
@@ -0,0 +1,168 @@
|
||||
'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)]">
|
||||
{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 {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,19 +1,46 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { WeeklySummary, WeeklyActivity } from '@/services/weekly-summary';
|
||||
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] = useState<WeeklySummary>(initialSummary);
|
||||
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);
|
||||
@@ -21,6 +48,18 @@ export default function WeeklySummaryClient({ initialSummary }: WeeklySummaryCli
|
||||
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',
|
||||
@@ -40,101 +79,309 @@ export default function WeeklySummaryClient({ initialSummary }: WeeklySummaryCli
|
||||
return type === 'checkbox' ? 'Daily' : 'Tâche';
|
||||
};
|
||||
|
||||
const filteredActivities = selectedDay
|
||||
// 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 (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 className="text-lg font-semibold">📅 Résumé de la semaine</h2>
|
||||
<p className="text-sm text-[var(--muted-foreground)]">
|
||||
Du {formatDate(summary.period.start)} au {formatDate(summary.period.end)}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleRefresh}
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
disabled={isRefreshing}
|
||||
<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)]'
|
||||
}`}
|
||||
>
|
||||
{isRefreshing ? '🔄' : '🔄'} {isRefreshing ? 'Actualisation...' : 'Actualiser'}
|
||||
</Button>
|
||||
</div>
|
||||
</CardHeader>
|
||||
📊 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 */}
|
||||
<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}
|
||||
{/* 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="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 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="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 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="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 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 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</h3>
|
||||
<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) => (
|
||||
<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">
|
||||
{day.completedCheckboxes + day.completedTasks}
|
||||
</div>
|
||||
<div className="text-xs text-[var(--muted-foreground)]">
|
||||
/{day.checkboxes + day.tasks}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
{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"
|
||||
@@ -148,9 +395,9 @@ export default function WeeklySummaryClient({ initialSummary }: WeeklySummaryCli
|
||||
{/* Timeline des activités */}
|
||||
<div>
|
||||
<h3 className="font-medium mb-3">
|
||||
🕒 Timeline des activités
|
||||
🕒 Timeline des activités {activeTab !== 'all' && `- ${activeTab}`}
|
||||
<span className="text-sm font-normal text-[var(--muted-foreground)]">
|
||||
({filteredActivities.length} items)
|
||||
({filteredActivities.length} items{activeTab !== 'all' && ` de la catégorie ${activeTab}`})
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -196,5 +443,6 @@ export default function WeeklySummaryClient({ initialSummary }: WeeklySummaryCli
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export function Header({ title = "TowerControl", subtitle = "Task Management", s
|
||||
{ href: '/', label: 'Dashboard' },
|
||||
{ href: '/kanban', label: 'Kanban' },
|
||||
{ href: '/daily', label: 'Daily' },
|
||||
{ href: '/weekly-summary', label: 'Résumé' },
|
||||
{ href: '/weekly-summary', label: 'Hebdo' },
|
||||
{ href: '/tags', label: 'Tags' },
|
||||
...(isJiraConfigured ? [{ href: '/jira-dashboard', label: `Jira${jiraConfig?.projectKey ? ` (${jiraConfig.projectKey})` : ''}` }] : []),
|
||||
{ href: '/settings', label: 'Settings' }
|
||||
|
||||
233
package-lock.json
generated
233
package-lock.json
generated
@@ -12,8 +12,10 @@
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@prisma/client": "^6.16.1",
|
||||
"@types/jspdf": "^1.3.3",
|
||||
"clsx": "^2.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"jspdf": "^3.0.3",
|
||||
"next": "15.5.3",
|
||||
"prisma": "^6.16.1",
|
||||
"react": "19.1.0",
|
||||
@@ -51,6 +53,15 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.28.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz",
|
||||
"integrity": "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@dnd-kit/accessibility": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.1.1.tgz",
|
||||
@@ -2035,6 +2046,12 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/jspdf": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/jspdf/-/jspdf-1.3.3.tgz",
|
||||
"integrity": "sha512-DqwyAKpVuv+7DniCp2Deq1xGvfdnKSNgl9Agun2w6dFvR5UKamiv4VfYUgcypd8S9ojUyARFIlZqBrYrBMQlew==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.19.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.14.tgz",
|
||||
@@ -2045,6 +2062,19 @@
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/pako": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/pako/-/pako-2.0.4.tgz",
|
||||
"integrity": "sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/raf": {
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz",
|
||||
"integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
"version": "19.1.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.13.tgz",
|
||||
@@ -2065,6 +2095,13 @@
|
||||
"@types/react": "^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@types/use-sync-external-store": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
|
||||
@@ -3000,6 +3037,16 @@
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/base64-arraybuffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
|
||||
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
@@ -3254,6 +3301,26 @@
|
||||
],
|
||||
"license": "CC-BY-4.0"
|
||||
},
|
||||
"node_modules/canvg": {
|
||||
"version": "3.0.11",
|
||||
"resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.11.tgz",
|
||||
"integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@types/raf": "^3.4.0",
|
||||
"core-js": "^3.8.3",
|
||||
"raf": "^3.4.1",
|
||||
"regenerator-runtime": "^0.13.7",
|
||||
"rgbcolor": "^1.0.1",
|
||||
"stackblur-canvas": "^2.0.0",
|
||||
"svg-pathdata": "^6.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
@@ -3413,6 +3480,18 @@
|
||||
"license": "ISC",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/core-js": {
|
||||
"version": "3.45.1",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.45.1.tgz",
|
||||
"integrity": "sha512-L4NPsJlCfZsPeXukyzHFlg/i7IIVwHSItR0wg0FLNqYClJ4MQYTYLbC7EkjKYRLZF2iof2MUgN0EGy7MdQFChg==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/core-js"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
@@ -3428,6 +3507,16 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/css-line-break": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz",
|
||||
"integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"utrie": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/csstype": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
||||
@@ -3768,6 +3857,16 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "3.2.7",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.7.tgz",
|
||||
"integrity": "sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==",
|
||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||
"optional": true,
|
||||
"optionalDependencies": {
|
||||
"@types/trusted-types": "^2.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.6.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
|
||||
@@ -4687,6 +4786,17 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-png": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-png/-/fast-png-6.4.0.tgz",
|
||||
"integrity": "sha512-kAqZq1TlgBjZcLr5mcN6NP5Rv4V2f22z00c3g8vRrwkcqjerx7BEhPbOnWCPqaHUl2XWQBJQvOT/FQhdMT7X/Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/pako": "^2.0.3",
|
||||
"iobuffer": "^5.3.2",
|
||||
"pako": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fastq": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz",
|
||||
@@ -4697,6 +4807,12 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz",
|
||||
"integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
||||
@@ -5171,6 +5287,20 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/html2canvas": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz",
|
||||
"integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"css-line-break": "^2.1.0",
|
||||
"text-segmentation": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/http-cache-semantics": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz",
|
||||
@@ -5362,6 +5492,12 @@
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/iobuffer": {
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/iobuffer/-/iobuffer-5.4.0.tgz",
|
||||
"integrity": "sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ip-address": {
|
||||
"version": "10.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.0.1.tgz",
|
||||
@@ -5892,6 +6028,23 @@
|
||||
"json5": "lib/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/jspdf": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/jspdf/-/jspdf-3.0.3.tgz",
|
||||
"integrity": "sha512-eURjAyz5iX1H8BOYAfzvdPfIKK53V7mCpBTe7Kb16PaM8JSXEcUQNBQaiWMI8wY5RvNOPj4GccMjTlfwRBd+oQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.26.9",
|
||||
"fast-png": "^6.2.0",
|
||||
"fflate": "^0.8.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"canvg": "^3.0.11",
|
||||
"core-js": "^3.6.0",
|
||||
"dompurify": "^3.2.4",
|
||||
"html2canvas": "^1.0.0-rc.5"
|
||||
}
|
||||
},
|
||||
"node_modules/jsx-ast-utils": {
|
||||
"version": "3.3.5",
|
||||
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz",
|
||||
@@ -6954,6 +7107,12 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/pako": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
|
||||
"integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==",
|
||||
"license": "(MIT AND Zlib)"
|
||||
},
|
||||
"node_modules/parent-module": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
||||
@@ -7016,6 +7175,13 @@
|
||||
"integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/performance-now": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
@@ -7265,6 +7431,16 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/raf": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
|
||||
"integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"performance-now": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rc": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
|
||||
@@ -7441,6 +7617,13 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/regenerator-runtime": {
|
||||
"version": "0.13.11",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/regexp.prototype.flags": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz",
|
||||
@@ -7530,6 +7713,16 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rgbcolor": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz",
|
||||
"integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==",
|
||||
"license": "MIT OR SEE LICENSE IN FEEL-FREE.md",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">= 0.8.15"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||
@@ -8051,6 +8244,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/stackblur-canvas": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz",
|
||||
"integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=0.1.14"
|
||||
}
|
||||
},
|
||||
"node_modules/stop-iteration-iterator": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz",
|
||||
@@ -8294,6 +8497,16 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/svg-pathdata": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz",
|
||||
"integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/synckit": {
|
||||
"version": "0.11.11",
|
||||
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.11.tgz",
|
||||
@@ -8452,6 +8665,16 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/text-segmentation": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz",
|
||||
"integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"utrie": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/tiny-invariant": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
|
||||
@@ -8800,6 +9023,16 @@
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/utrie": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz",
|
||||
"integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"base64-arraybuffer": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/victory-vendor": {
|
||||
"version": "37.3.6",
|
||||
"resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-37.3.6.tgz",
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@prisma/client": "^6.16.1",
|
||||
"@types/jspdf": "^1.3.3",
|
||||
"clsx": "^2.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"jspdf": "^3.0.3",
|
||||
"next": "15.5.3",
|
||||
"prisma": "^6.16.1",
|
||||
"react": "19.1.0",
|
||||
|
||||
180
services/jira-summary.ts
Normal file
180
services/jira-summary.ts
Normal file
@@ -0,0 +1,180 @@
|
||||
import type { JiraConfig } from './jira';
|
||||
import { Task } from '@/lib/types';
|
||||
|
||||
export interface JiraWeeklyMetrics {
|
||||
totalJiraTasks: number;
|
||||
completedJiraTasks: number;
|
||||
totalStoryPoints: number; // Estimation basée sur le type de ticket
|
||||
projectsContributed: string[];
|
||||
ticketTypes: { [type: string]: number };
|
||||
jiraLinks: Array<{
|
||||
key: string;
|
||||
title: string;
|
||||
status: string;
|
||||
type: string;
|
||||
url: string;
|
||||
estimatedPoints: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export class JiraSummaryService {
|
||||
/**
|
||||
* Enrichit les tâches hebdomadaires avec des métriques Jira
|
||||
*/
|
||||
static async getJiraWeeklyMetrics(
|
||||
weeklyTasks: Task[],
|
||||
jiraConfig?: JiraConfig
|
||||
): Promise<JiraWeeklyMetrics | null> {
|
||||
|
||||
if (!jiraConfig?.baseUrl || !jiraConfig?.email || !jiraConfig?.apiToken) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const jiraTasks = weeklyTasks.filter(task =>
|
||||
task.source === 'jira' && task.jiraKey && task.jiraProject
|
||||
);
|
||||
|
||||
if (jiraTasks.length === 0) {
|
||||
return {
|
||||
totalJiraTasks: 0,
|
||||
completedJiraTasks: 0,
|
||||
totalStoryPoints: 0,
|
||||
projectsContributed: [],
|
||||
ticketTypes: {},
|
||||
jiraLinks: []
|
||||
};
|
||||
}
|
||||
|
||||
// Calculer les métriques basiques
|
||||
const completedJiraTasks = jiraTasks.filter(task => task.status === 'done');
|
||||
const projectsContributed = [...new Set(jiraTasks.map(task => task.jiraProject).filter((project): project is string => Boolean(project)))];
|
||||
|
||||
// Analyser les types de tickets
|
||||
const ticketTypes: { [type: string]: number } = {};
|
||||
jiraTasks.forEach(task => {
|
||||
const type = task.jiraType || 'Unknown';
|
||||
ticketTypes[type] = (ticketTypes[type] || 0) + 1;
|
||||
});
|
||||
|
||||
// Estimer les story points basés sur le type de ticket
|
||||
const estimateStoryPoints = (type: string): number => {
|
||||
const typeMapping: { [key: string]: number } = {
|
||||
'Story': 3,
|
||||
'Task': 2,
|
||||
'Bug': 1,
|
||||
'Epic': 8,
|
||||
'Sub-task': 1,
|
||||
'Improvement': 2,
|
||||
'New Feature': 5,
|
||||
'défaut': 1, // French
|
||||
'amélioration': 2, // French
|
||||
'nouvelle fonctionnalité': 5, // French
|
||||
};
|
||||
|
||||
return typeMapping[type] || typeMapping[type?.toLowerCase()] || 2; // Défaut: 2 points
|
||||
};
|
||||
|
||||
const totalStoryPoints = jiraTasks.reduce((sum, task) => {
|
||||
return sum + estimateStoryPoints(task.jiraType || '');
|
||||
}, 0);
|
||||
|
||||
// Créer les liens Jira
|
||||
const jiraLinks = jiraTasks.map(task => ({
|
||||
key: task.jiraKey || '',
|
||||
title: task.title,
|
||||
status: task.status,
|
||||
type: task.jiraType || 'Unknown',
|
||||
url: `${jiraConfig.baseUrl.replace('/rest/api/3', '')}/browse/${task.jiraKey}`,
|
||||
estimatedPoints: estimateStoryPoints(task.jiraType || '')
|
||||
}));
|
||||
|
||||
return {
|
||||
totalJiraTasks: jiraTasks.length,
|
||||
completedJiraTasks: completedJiraTasks.length,
|
||||
totalStoryPoints,
|
||||
projectsContributed,
|
||||
ticketTypes,
|
||||
jiraLinks
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la configuration Jira depuis les préférences utilisateur
|
||||
*/
|
||||
static async getJiraConfig(): Promise<JiraConfig | null> {
|
||||
try {
|
||||
// Import dynamique pour éviter les cycles de dépendance
|
||||
const { userPreferencesService } = await import('./user-preferences');
|
||||
const preferences = await userPreferencesService.getAllPreferences();
|
||||
|
||||
if (!preferences.jiraConfig?.baseUrl ||
|
||||
!preferences.jiraConfig?.email ||
|
||||
!preferences.jiraConfig?.apiToken) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
baseUrl: preferences.jiraConfig.baseUrl,
|
||||
email: preferences.jiraConfig.email,
|
||||
apiToken: preferences.jiraConfig.apiToken,
|
||||
projectKey: preferences.jiraConfig.projectKey,
|
||||
ignoredProjects: preferences.jiraConfig.ignoredProjects
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la récupération de la config Jira:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Génère des insights business basés sur les métriques Jira
|
||||
*/
|
||||
static generateBusinessInsights(jiraMetrics: JiraWeeklyMetrics): string[] {
|
||||
const insights: string[] = [];
|
||||
|
||||
if (jiraMetrics.totalJiraTasks === 0) {
|
||||
insights.push("Aucune tâche Jira cette semaine. Concentré sur des tâches internes ?");
|
||||
return insights;
|
||||
}
|
||||
|
||||
// Insights sur la completion
|
||||
const completionRate = (jiraMetrics.completedJiraTasks / jiraMetrics.totalJiraTasks) * 100;
|
||||
if (completionRate >= 80) {
|
||||
insights.push(`🎯 Excellent taux de completion Jira: ${completionRate.toFixed(0)}%`);
|
||||
} else if (completionRate < 50) {
|
||||
insights.push(`⚠️ Taux de completion Jira faible: ${completionRate.toFixed(0)}%. Revoir les estimations ?`);
|
||||
}
|
||||
|
||||
// Insights sur les story points
|
||||
if (jiraMetrics.totalStoryPoints > 0) {
|
||||
insights.push(`📊 Estimation: ${jiraMetrics.totalStoryPoints} story points traités cette semaine`);
|
||||
|
||||
const avgPointsPerTask = jiraMetrics.totalStoryPoints / jiraMetrics.totalJiraTasks;
|
||||
if (avgPointsPerTask > 4) {
|
||||
insights.push(`🏋️ Travail sur des tâches complexes (${avgPointsPerTask.toFixed(1)} pts/tâche en moyenne)`);
|
||||
}
|
||||
}
|
||||
|
||||
// Insights sur les projets
|
||||
if (jiraMetrics.projectsContributed.length > 1) {
|
||||
insights.push(`🤝 Contribution multi-projets: ${jiraMetrics.projectsContributed.join(', ')}`);
|
||||
} else if (jiraMetrics.projectsContributed.length === 1) {
|
||||
insights.push(`🎯 Focus sur le projet ${jiraMetrics.projectsContributed[0]}`);
|
||||
}
|
||||
|
||||
// Insights sur les types de tickets
|
||||
const bugCount = jiraMetrics.ticketTypes['Bug'] || jiraMetrics.ticketTypes['défaut'] || 0;
|
||||
const totalTickets = Object.values(jiraMetrics.ticketTypes).reduce((sum, count) => sum + count, 0);
|
||||
|
||||
if (bugCount > 0) {
|
||||
const bugRatio = (bugCount / totalTickets) * 100;
|
||||
if (bugRatio > 50) {
|
||||
insights.push(`🐛 Semaine focalisée sur la correction de bugs (${bugRatio.toFixed(0)}%)`);
|
||||
} else if (bugRatio < 20) {
|
||||
insights.push(`✨ Semaine productive avec peu de bugs (${bugRatio.toFixed(0)}%)`);
|
||||
}
|
||||
}
|
||||
|
||||
return insights;
|
||||
}
|
||||
}
|
||||
193
services/pdf-export.ts
Normal file
193
services/pdf-export.ts
Normal file
@@ -0,0 +1,193 @@
|
||||
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)}%`;
|
||||
}
|
||||
}
|
||||
|
||||
185
services/task-categorization.ts
Normal file
185
services/task-categorization.ts
Normal file
@@ -0,0 +1,185 @@
|
||||
export interface PredefinedCategory {
|
||||
name: string;
|
||||
color: string;
|
||||
keywords: string[];
|
||||
icon: string;
|
||||
}
|
||||
|
||||
export const PREDEFINED_CATEGORIES: PredefinedCategory[] = [
|
||||
{
|
||||
name: 'Dev',
|
||||
color: '#3b82f6', // Blue
|
||||
icon: '💻',
|
||||
keywords: [
|
||||
'code', 'coding', 'development', 'develop', 'dev', 'programming', 'program',
|
||||
'bug', 'fix', 'debug', 'feature', 'implement', 'refactor', 'review',
|
||||
'api', 'database', 'db', 'frontend', 'backend', 'ui', 'ux',
|
||||
'component', 'service', 'function', 'method', 'class',
|
||||
'git', 'commit', 'merge', 'pull request', 'pr', 'deploy', 'deployment',
|
||||
'test', 'testing', 'unit test', 'integration'
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Meeting',
|
||||
color: '#8b5cf6', // Purple
|
||||
icon: '🤝',
|
||||
keywords: [
|
||||
'meeting', 'réunion', 'call', 'standup', 'daily', 'retrospective', 'retro',
|
||||
'planning', 'demo', 'presentation', 'sync', 'catch up', 'catchup',
|
||||
'interview', 'discussion', 'brainstorm', 'workshop', 'session',
|
||||
'one on one', '1on1', 'review meeting', 'sprint planning'
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Admin',
|
||||
color: '#6b7280', // Gray
|
||||
icon: '📋',
|
||||
keywords: [
|
||||
'admin', 'administration', 'paperwork', 'documentation', 'doc', 'docs',
|
||||
'report', 'reporting', 'timesheet', 'expense', 'invoice',
|
||||
'email', 'mail', 'communication', 'update', 'status',
|
||||
'config', 'configuration', 'setup', 'installation', 'maintenance',
|
||||
'backup', 'security', 'permission', 'user management'
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Learning',
|
||||
color: '#10b981', // Green
|
||||
icon: '📚',
|
||||
keywords: [
|
||||
'learning', 'learn', 'study', 'training', 'course', 'tutorial',
|
||||
'research', 'reading', 'documentation', 'knowledge', 'skill',
|
||||
'certification', 'workshop', 'seminar', 'conference',
|
||||
'practice', 'exercise', 'experiment', 'exploration', 'investigate'
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export class TaskCategorizationService {
|
||||
/**
|
||||
* Suggère une catégorie basée sur le titre et la description d'une tâche
|
||||
*/
|
||||
static suggestCategory(title: string, description?: string): PredefinedCategory | null {
|
||||
const text = `${title} ${description || ''}`.toLowerCase();
|
||||
|
||||
// Compte les matches pour chaque catégorie
|
||||
const categoryScores = PREDEFINED_CATEGORIES.map(category => {
|
||||
const matches = category.keywords.filter(keyword =>
|
||||
text.includes(keyword.toLowerCase())
|
||||
).length;
|
||||
|
||||
return {
|
||||
category,
|
||||
score: matches
|
||||
};
|
||||
});
|
||||
|
||||
// Trouve la meilleure catégorie
|
||||
const bestMatch = categoryScores.reduce((best, current) =>
|
||||
current.score > best.score ? current : best
|
||||
);
|
||||
|
||||
// Retourne la catégorie seulement s'il y a au moins un match
|
||||
return bestMatch.score > 0 ? bestMatch.category : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggère plusieurs catégories avec leur score de confiance
|
||||
*/
|
||||
static suggestCategoriesWithScore(title: string, description?: string): Array<{
|
||||
category: PredefinedCategory;
|
||||
score: number;
|
||||
confidence: number;
|
||||
}> {
|
||||
const text = `${title} ${description || ''}`.toLowerCase();
|
||||
|
||||
const categoryScores = PREDEFINED_CATEGORIES.map(category => {
|
||||
const matches = category.keywords.filter(keyword =>
|
||||
text.includes(keyword.toLowerCase())
|
||||
);
|
||||
|
||||
const score = matches.length;
|
||||
const confidence = Math.min((score / 3) * 100, 100); // Max 100% de confiance avec 3+ mots-clés
|
||||
|
||||
return {
|
||||
category,
|
||||
score,
|
||||
confidence
|
||||
};
|
||||
});
|
||||
|
||||
return categoryScores
|
||||
.filter(item => item.score > 0)
|
||||
.sort((a, b) => b.score - a.score);
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyse les activités et retourne la répartition par catégorie
|
||||
*/
|
||||
static analyzeActivitiesByCategory(activities: Array<{ title: string; description?: string }>): {
|
||||
[categoryName: string]: {
|
||||
count: number;
|
||||
percentage: number;
|
||||
color: string;
|
||||
icon: string;
|
||||
}
|
||||
} {
|
||||
const categoryCounts: { [key: string]: number } = {};
|
||||
const uncategorized = { count: 0 };
|
||||
|
||||
// Initialiser les compteurs
|
||||
PREDEFINED_CATEGORIES.forEach(cat => {
|
||||
categoryCounts[cat.name] = 0;
|
||||
});
|
||||
|
||||
// Analyser chaque activité
|
||||
activities.forEach(activity => {
|
||||
const suggestedCategory = this.suggestCategory(activity.title, activity.description);
|
||||
|
||||
if (suggestedCategory) {
|
||||
categoryCounts[suggestedCategory.name]++;
|
||||
} else {
|
||||
uncategorized.count++;
|
||||
}
|
||||
});
|
||||
|
||||
const total = activities.length;
|
||||
const result: { [categoryName: string]: { count: number; percentage: number; color: string; icon: string } } = {};
|
||||
|
||||
// Ajouter les catégories prédéfinies
|
||||
PREDEFINED_CATEGORIES.forEach(category => {
|
||||
const count = categoryCounts[category.name];
|
||||
result[category.name] = {
|
||||
count,
|
||||
percentage: total > 0 ? (count / total) * 100 : 0,
|
||||
color: category.color,
|
||||
icon: category.icon
|
||||
};
|
||||
});
|
||||
|
||||
// Ajouter "Autre" si nécessaire
|
||||
if (uncategorized.count > 0) {
|
||||
result['Autre'] = {
|
||||
count: uncategorized.count,
|
||||
percentage: total > 0 ? (uncategorized.count / total) * 100 : 0,
|
||||
color: '#d1d5db',
|
||||
icon: '❓'
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les tags suggérés pour une tâche
|
||||
*/
|
||||
static getSuggestedTags(title: string, description?: string): string[] {
|
||||
const suggestions = this.suggestCategoriesWithScore(title, description);
|
||||
|
||||
return suggestions
|
||||
.filter(s => s.confidence >= 30) // Seulement les suggestions avec 30%+ de confiance
|
||||
.slice(0, 2) // Maximum 2 suggestions
|
||||
.map(s => s.category.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { prisma } from './database';
|
||||
import { Task, TaskStatus, TaskPriority, TaskSource } from '@/lib/types';
|
||||
import { TaskCategorizationService } from './task-categorization';
|
||||
|
||||
export interface DailyItem {
|
||||
id: string;
|
||||
@@ -39,44 +40,99 @@ export interface WeeklyActivity {
|
||||
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(): Promise<WeeklySummary> {
|
||||
static async getWeeklySummary(periodDays: number = 7): Promise<WeeklySummary> {
|
||||
const now = new Date();
|
||||
const startOfWeek = new Date(now);
|
||||
startOfWeek.setDate(now.getDate() - 7);
|
||||
startOfWeek.setHours(0, 0, 0, 0);
|
||||
const startOfPeriod = new Date(now);
|
||||
startOfPeriod.setDate(now.getDate() - periodDays);
|
||||
startOfPeriod.setHours(0, 0, 0, 0);
|
||||
|
||||
const endOfWeek = new Date(now);
|
||||
endOfWeek.setHours(23, 59, 59, 999);
|
||||
const endOfPeriod = new Date(now);
|
||||
endOfPeriod.setHours(23, 59, 59, 999);
|
||||
|
||||
console.log(`📊 Génération du résumé hebdomadaire du ${startOfWeek.toLocaleDateString()} au ${endOfWeek.toLocaleDateString()}`);
|
||||
console.log(`📊 Génération du résumé (${periodDays} jours) du ${startOfPeriod.toLocaleDateString()} au ${endOfPeriod.toLocaleDateString()}`);
|
||||
|
||||
const [checkboxes, tasks] = await Promise.all([
|
||||
this.getWeeklyCheckboxes(startOfWeek, endOfWeek),
|
||||
this.getWeeklyTasks(startOfWeek, endOfWeek)
|
||||
const [checkboxes, tasks, velocity] = await Promise.all([
|
||||
this.getWeeklyCheckboxes(startOfPeriod, endOfPeriod),
|
||||
this.getWeeklyTasks(startOfPeriod, endOfPeriod),
|
||||
this.calculateVelocityMetrics(endOfPeriod)
|
||||
]);
|
||||
|
||||
const stats = this.calculateStats(checkboxes, tasks, startOfWeek, endOfWeek);
|
||||
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: startOfWeek,
|
||||
end: endOfWeek
|
||||
start: startOfPeriod,
|
||||
end: endOfPeriod
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -214,6 +270,128 @@ export class WeeklySummaryService {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
36
src/app/api/weekly-summary/route.ts
Normal file
36
src/app/api/weekly-summary/route.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user