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.
This commit is contained in:
@@ -26,7 +26,7 @@ interface KanbanFiltersProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps) {
|
export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps) {
|
||||||
const { tags: availableTags, tasks } = useTasksContext();
|
const { tags: availableTags, regularTasks } = useTasksContext();
|
||||||
const [isExpanded, setIsExpanded] = useState(false);
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
const [isSortExpanded, setIsSortExpanded] = useState(false);
|
const [isSortExpanded, setIsSortExpanded] = useState(false);
|
||||||
const sortDropdownRef = useRef<HTMLDivElement>(null);
|
const sortDropdownRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -117,19 +117,19 @@ export function KanbanFilters({ filters, onFiltersChange }: KanbanFiltersProps)
|
|||||||
const priorityCounts = useMemo(() => {
|
const priorityCounts = useMemo(() => {
|
||||||
const counts: Record<string, number> = {};
|
const counts: Record<string, number> = {};
|
||||||
getAllPriorities().forEach(priority => {
|
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;
|
return counts;
|
||||||
}, [tasks]);
|
}, [regularTasks]);
|
||||||
|
|
||||||
// Calculer les compteurs pour les tags
|
// Calculer les compteurs pour les tags
|
||||||
const tagCounts = useMemo(() => {
|
const tagCounts = useMemo(() => {
|
||||||
const counts: Record<string, number> = {};
|
const counts: Record<string, number> = {};
|
||||||
availableTags.forEach(tag => {
|
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;
|
return counts;
|
||||||
}, [tasks, availableTags]);
|
}, [regularTasks, availableTags]);
|
||||||
|
|
||||||
const priorityOptions = getAllPriorities().map(priorityConfig => ({
|
const priorityOptions = getAllPriorities().map(priorityConfig => ({
|
||||||
value: priorityConfig.key,
|
value: priorityConfig.key,
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import { KanbanFilters } from '@/components/kanban/KanbanFilters';
|
|||||||
import { sortTasks, getSortOption, DEFAULT_SORT, createSortKey } from '@/lib/sort-config';
|
import { sortTasks, getSortOption, DEFAULT_SORT, createSortKey } from '@/lib/sort-config';
|
||||||
|
|
||||||
interface TasksContextType {
|
interface TasksContextType {
|
||||||
tasks: Task[];
|
tasks: Task[]; // Toutes les tâches
|
||||||
|
regularTasks: Task[]; // Tâches sans les épinglées (pour Kanban)
|
||||||
stats: {
|
stats: {
|
||||||
total: number;
|
total: number;
|
||||||
completed: number;
|
completed: number;
|
||||||
@@ -175,6 +176,7 @@ export function TasksProvider({ children, initialTasks, initialStats, initialTag
|
|||||||
|
|
||||||
const contextValue: TasksContextType = {
|
const contextValue: TasksContextType = {
|
||||||
...tasksState,
|
...tasksState,
|
||||||
|
regularTasks,
|
||||||
tags,
|
tags,
|
||||||
tagsLoading,
|
tagsLoading,
|
||||||
tagsError,
|
tagsError,
|
||||||
|
|||||||
Reference in New Issue
Block a user