feat: enhance HomePage with tag metrics and analytics integration

- Added TagAnalyticsService to fetch tag distribution metrics for the HomePage.
- Updated HomePageClient and ProductivityAnalytics components to utilize new tag metrics.
- Refactored TagsClient to use utility functions for color validation and generation.
- Simplified TagForm to use centralized tag colors from TAG_COLORS.
This commit is contained in:
Julien Froidefond
2025-10-03 08:37:43 +02:00
parent 735070dd6f
commit 1dfb8f8ac1
9 changed files with 572 additions and 48 deletions

View File

@@ -1,5 +1,6 @@
import { HttpClient } from './base/http-client';
import { Tag } from '@/lib/types';
import { generateRandomTagColor, isValidTagColor } from '@/lib/tag-colors';
// Types pour les requêtes (now only used for validation - CRUD operations moved to server actions)
@@ -85,27 +86,14 @@ export class TagsClient extends HttpClient {
* Valide le format d'une couleur hexadécimale
*/
static isValidColor(color: string): boolean {
return /^#[0-9A-F]{6}$/i.test(color);
return isValidTagColor(color);
}
/**
* Génère une couleur aléatoire pour un nouveau tag
*/
static generateRandomColor(): string {
const colors = [
'#3B82F6', // Blue
'#EF4444', // Red
'#10B981', // Green
'#F59E0B', // Yellow
'#8B5CF6', // Purple
'#EC4899', // Pink
'#06B6D4', // Cyan
'#84CC16', // Lime
'#F97316', // Orange
'#6366F1', // Indigo
];
return colors[Math.floor(Math.random() * colors.length)];
return generateRandomTagColor();
}
/**