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:
Julien Froidefond
2025-09-15 08:17:45 +02:00
parent e6d24f2693
commit d681a6c127
7 changed files with 104 additions and 41 deletions

View File

@@ -5,6 +5,7 @@ import { TaskPriority } from '@/lib/types';
import { Button } from '@/components/ui/Button';
import { Input } from '@/components/ui/Input';
import { useTasksContext } from '@/contexts/TasksContext';
import { getAllPriorities, getPriorityColorHex } from '@/lib/status-config';
export interface KanbanFilters {
search?: string;
@@ -67,26 +68,17 @@ export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps)
});
};
const handlePinnedTagChange = (tagName: string | undefined) => {
onFiltersChange({
...filters,
pinnedTag: tagName
});
};
const handleClearFilters = () => {
onFiltersChange({});
};
const hasActiveFilters = filters.search || filters.tags?.length || filters.priorities?.length;
const activeFiltersCount = (filters.tags?.length || 0) + (filters.priorities?.length || 0) + (filters.search ? 1 : 0);
const priorityOptions: { value: TaskPriority; label: string; color: string }[] = [
{ value: 'urgent', label: 'Urgent', color: 'bg-red-500' },
{ value: 'high', label: 'Haute', color: 'bg-orange-500' },
{ value: 'medium', label: 'Moyenne', color: 'bg-yellow-500' },
{ value: 'low', label: 'Basse', color: 'bg-blue-500' }
];
const priorityOptions = getAllPriorities().map(priorityConfig => ({
value: priorityConfig.key,
label: priorityConfig.label,
color: priorityConfig.color
}));
return (
<div className="bg-slate-900/50 border-b border-slate-700/50 backdrop-blur-sm">
@@ -198,7 +190,10 @@ export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps)
: 'border-slate-600 bg-slate-800/50 text-slate-400 hover:border-slate-500'
}`}
>
<div className={`w-2 h-2 rounded-full ${priority.color}`} />
<div
className="w-2 h-2 rounded-full"
style={{ backgroundColor: getPriorityColorHex(priority.color) }}
/>
{priority.label}
</button>
))}