feat: enhance task forms and Kanban components with dynamic priority loading
- Updated `CreateTaskForm` and `EditTaskForm` to load priority options dynamically using `getAllPriorities`, improving maintainability. - Refactored `KanbanFilters` to utilize dynamic priority options, enhancing filter functionality. - Modified `QuickAddTask` and `TaskCard` to display priorities using centralized configuration, ensuring consistency across the application. - Introduced new utility functions in `status-config.ts` for managing priority configurations, streamlining the task management process.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { TaskStatus } from './types';
|
||||
import { TaskStatus, TaskPriority } from './types';
|
||||
|
||||
export interface StatusConfig {
|
||||
key: TaskStatus;
|
||||
@@ -114,3 +114,74 @@ export const getBadgeVariant = (color: StatusConfig['color']): 'success' | 'prim
|
||||
default: return 'default';
|
||||
}
|
||||
};
|
||||
|
||||
// Configuration des priorités
|
||||
export interface PriorityConfig {
|
||||
key: TaskPriority;
|
||||
label: string;
|
||||
icon: string;
|
||||
color: 'blue' | 'yellow' | 'purple' | 'red';
|
||||
order: number;
|
||||
}
|
||||
|
||||
export const PRIORITY_CONFIG: Record<TaskPriority, PriorityConfig> = {
|
||||
low: {
|
||||
key: 'low',
|
||||
label: 'Faible',
|
||||
icon: '🔵',
|
||||
color: 'blue',
|
||||
order: 1
|
||||
},
|
||||
medium: {
|
||||
key: 'medium',
|
||||
label: 'Moyenne',
|
||||
icon: '🟡',
|
||||
color: 'yellow',
|
||||
order: 2
|
||||
},
|
||||
high: {
|
||||
key: 'high',
|
||||
label: 'Élevée',
|
||||
icon: '🟣',
|
||||
color: 'purple',
|
||||
order: 3
|
||||
},
|
||||
urgent: {
|
||||
key: 'urgent',
|
||||
label: 'Urgente',
|
||||
icon: '🔴',
|
||||
color: 'red',
|
||||
order: 4
|
||||
}
|
||||
} as const;
|
||||
|
||||
// Utilitaires pour les priorités
|
||||
export const getPriorityConfig = (priority: TaskPriority): PriorityConfig => {
|
||||
return PRIORITY_CONFIG[priority];
|
||||
};
|
||||
|
||||
export const getAllPriorities = (): PriorityConfig[] => {
|
||||
return Object.values(PRIORITY_CONFIG).sort((a, b) => a.order - b.order);
|
||||
};
|
||||
|
||||
export const getPriorityLabel = (priority: TaskPriority): string => {
|
||||
return PRIORITY_CONFIG[priority].label;
|
||||
};
|
||||
|
||||
export const getPriorityIcon = (priority: TaskPriority): string => {
|
||||
return PRIORITY_CONFIG[priority].icon;
|
||||
};
|
||||
|
||||
export const getPriorityColor = (priority: TaskPriority): PriorityConfig['color'] => {
|
||||
return PRIORITY_CONFIG[priority].color;
|
||||
};
|
||||
|
||||
export const getPriorityColorHex = (color: PriorityConfig['color']): string => {
|
||||
const colorMap = {
|
||||
blue: '#60a5fa',
|
||||
yellow: '#fbbf24',
|
||||
purple: '#a78bfa',
|
||||
red: '#f87171'
|
||||
};
|
||||
return colorMap[color];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user