feat: refactor color management in charts and dashboard
- Replaced hardcoded priority colors in `PriorityDistributionChart` and `DashboardStats` with centralized configuration functions for better maintainability. - Updated `RecentTasks` to utilize new status badge classes and labels from the centralized configuration. - Enhanced `status-config.ts` with new functions for retrieving colors and styles, ensuring consistency across components. - Marked the task for refactoring priority colors in TODO.md as complete.
This commit is contained in:
@@ -5,7 +5,7 @@ import { Card } from '@/components/ui/Card';
|
||||
import { TagDisplay } from '@/components/ui/TagDisplay';
|
||||
import { Badge } from '@/components/ui/Badge';
|
||||
import { useTasksContext } from '@/contexts/TasksContext';
|
||||
import { getPriorityConfig, getPriorityColorHex } from '@/lib/status-config';
|
||||
import { getPriorityConfig, getPriorityColorHex, getStatusBadgeClasses, getStatusLabel } from '@/lib/status-config';
|
||||
import { TaskPriority } from '@/lib/types';
|
||||
import Link from 'next/link';
|
||||
|
||||
@@ -21,23 +21,7 @@ export function RecentTasks({ tasks }: RecentTasksProps) {
|
||||
.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime())
|
||||
.slice(0, 5);
|
||||
|
||||
const getStatusColor = (status: string) => {
|
||||
switch (status) {
|
||||
case 'todo': return 'bg-gray-100 text-gray-800';
|
||||
case 'inProgress': return 'bg-orange-100 text-orange-800';
|
||||
case 'done': return 'bg-green-100 text-green-800';
|
||||
default: return 'bg-gray-100 text-gray-800';
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusText = (status: string) => {
|
||||
switch (status) {
|
||||
case 'todo': return 'À faire';
|
||||
case 'inProgress': return 'En cours';
|
||||
case 'done': return 'Terminé';
|
||||
default: return status;
|
||||
}
|
||||
};
|
||||
// Fonctions simplifiées utilisant la configuration centralisée
|
||||
|
||||
const getPriorityStyle = (priority: string) => {
|
||||
try {
|
||||
@@ -93,8 +77,8 @@ export function RecentTasks({ tasks }: RecentTasksProps) {
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Badge className={`text-xs ${getStatusColor(task.status)}`}>
|
||||
{getStatusText(task.status)}
|
||||
<Badge className={`text-xs ${getStatusBadgeClasses(task.status)}`}>
|
||||
{getStatusLabel(task.status)}
|
||||
</Badge>
|
||||
|
||||
{task.priority && (
|
||||
|
||||
Reference in New Issue
Block a user