From bfe542bf108150e64e6a3255d15080bef600e499 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Mon, 15 Sep 2025 08:44:23 +0200 Subject: [PATCH] fix: update KanbanFilters to use regularTasks instead of tasks - Changed `tasks` to `regularTasks` in `KanbanFilters` for accurate task counting. - Updated priority and tag count calculations to reflect the new `regularTasks` prop, ensuring filters work with non-pinned tasks. - Adjusted `TasksContext` to provide `regularTasks`, enhancing task management clarity. --- components/kanban/KanbanFilters.tsx | 10 +++++----- src/contexts/TasksContext.tsx | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/kanban/KanbanFilters.tsx b/components/kanban/KanbanFilters.tsx index df93b50..a1a932b 100644 --- a/components/kanban/KanbanFilters.tsx +++ b/components/kanban/KanbanFilters.tsx @@ -26,7 +26,7 @@ interface KanbanFiltersProps { } export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps) { - const { tags: availableTags, tasks } = useTasksContext(); + const { tags: availableTags, regularTasks } = useTasksContext(); const [isExpanded, setIsExpanded] = useState(false); const [isSortExpanded, setIsSortExpanded] = useState(false); const sortDropdownRef = useRef(null); @@ -117,19 +117,19 @@ export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps) const priorityCounts = useMemo(() => { const counts: Record = {}; getAllPriorities().forEach(priority => { - counts[priority.key] = tasks.filter(task => task.priority === priority.key).length; + counts[priority.key] = regularTasks.filter(task => task.priority === priority.key).length; }); return counts; - }, [tasks]); + }, [regularTasks]); // Calculer les compteurs pour les tags const tagCounts = useMemo(() => { const counts: Record = {}; availableTags.forEach(tag => { - counts[tag.name] = tasks.filter(task => task.tags?.includes(tag.name)).length; + counts[tag.name] = regularTasks.filter(task => task.tags?.includes(tag.name)).length; }); return counts; - }, [tasks, availableTags]); + }, [regularTasks, availableTags]); const priorityOptions = getAllPriorities().map(priorityConfig => ({ value: priorityConfig.key, diff --git a/src/contexts/TasksContext.tsx b/src/contexts/TasksContext.tsx index 064616e..40e7413 100644 --- a/src/contexts/TasksContext.tsx +++ b/src/contexts/TasksContext.tsx @@ -10,7 +10,8 @@ import { KanbanFilters } from '@/components/kanban/KanbanFilters'; import { sortTasks, getSortOption, DEFAULT_SORT, createSortKey } from '@/lib/sort-config'; interface TasksContextType { - tasks: Task[]; + tasks: Task[]; // Toutes les tâches + regularTasks: Task[]; // Tâches sans les épinglées (pour Kanban) stats: { total: number; completed: number; @@ -175,6 +176,7 @@ export function TasksProvider({ children, initialTasks, initialStats, initialTag const contextValue: TasksContextType = { ...tasksState, + regularTasks, tags, tagsLoading, tagsError,