fix: add active filters count to context and components
- Integrated activeFiltersCount into useTasksContext for HomePageContent and KanbanFilters. - Removed redundant activeFiltersCount calculation from KanbanFilters, leveraging the context instead for better performance and consistency.
This commit is contained in:
@@ -27,6 +27,7 @@ interface TasksContextType {
|
||||
setKanbanFilters: (filters: KanbanFilters) => void;
|
||||
filteredTasks: Task[];
|
||||
pinnedTasks: Task[]; // Tâches avec tags épinglés (objectifs)
|
||||
activeFiltersCount: number; // Nombre de filtres actifs
|
||||
// Tags
|
||||
tags: Tag[];
|
||||
tagsLoading: boolean;
|
||||
@@ -126,6 +127,17 @@ export function TasksProvider({ children, initialTasks, initialStats, initialTag
|
||||
return { pinnedTasks: sortedPinned, regularTasks: regular };
|
||||
}, [tasksState.tasks, tags, kanbanFilters.sortBy]);
|
||||
|
||||
// Calcul du nombre de filtres actifs
|
||||
const activeFiltersCount = useMemo(() => {
|
||||
return (kanbanFilters.tags?.filter(Boolean).length || 0) +
|
||||
(kanbanFilters.priorities?.filter(Boolean).length || 0) +
|
||||
(kanbanFilters.search ? 1 : 0) +
|
||||
(kanbanFilters.jiraProjects?.filter(Boolean).length || 0) +
|
||||
(kanbanFilters.jiraTypes?.filter(Boolean).length || 0) +
|
||||
(kanbanFilters.showJiraOnly ? 1 : 0) +
|
||||
(kanbanFilters.hideJiraTasks ? 1 : 0);
|
||||
}, [kanbanFilters]);
|
||||
|
||||
// Filtrage et tri des tâches régulières (pas les épinglées)
|
||||
const filteredTasks = useMemo(() => {
|
||||
let filtered = regularTasks;
|
||||
@@ -203,7 +215,8 @@ export function TasksProvider({ children, initialTasks, initialStats, initialTag
|
||||
kanbanFilters,
|
||||
setKanbanFilters,
|
||||
filteredTasks,
|
||||
pinnedTasks
|
||||
pinnedTasks,
|
||||
activeFiltersCount
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user