From 026a175681f6fb3abfdabc1d4c874f889fc0681a Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Fri, 26 Sep 2025 08:09:08 +0200 Subject: [PATCH] feat: enhance RecentTasks component with task link and date formatting - Wrapped the task updated date in a flex container for better layout. - Added a link to the Kanban page for each task, allowing users to quickly access task details directly from the RecentTasks component. --- src/components/dashboard/RecentTasks.tsx | 15 ++++++++++++-- src/components/kanban/BoardContainer.tsx | 25 ++++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/components/dashboard/RecentTasks.tsx b/src/components/dashboard/RecentTasks.tsx index 92517b9..c3f487a 100644 --- a/src/components/dashboard/RecentTasks.tsx +++ b/src/components/dashboard/RecentTasks.tsx @@ -116,8 +116,19 @@ export function RecentTasks({ tasks }: RecentTasksProps) { -
- {formatDateShort(task.updatedAt)} +
+
+ {formatDateShort(task.updatedAt)} +
+ + + + +
diff --git a/src/components/kanban/BoardContainer.tsx b/src/components/kanban/BoardContainer.tsx index acc7b4f..1dcab88 100644 --- a/src/components/kanban/BoardContainer.tsx +++ b/src/components/kanban/BoardContainer.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { EditTaskForm } from '@/components/forms/EditTaskForm'; import { useTasksContext } from '@/contexts/TasksContext'; import { useUserPreferences } from '@/contexts/UserPreferencesContext'; @@ -39,15 +39,32 @@ export function KanbanBoardContainer({ const visibleStatuses = allStatuses.filter(status => isColumnVisible(status.key)).map(s => s.key); const [editingTask, setEditingTask] = useState(null); - // Effet pour ouvrir automatiquement la popup d'édition si un taskId est fourni dans l'URL + // Callback memoized pour appliquer le filtre de recherche + const applyTaskFilter = useCallback((taskToEdit: Task) => { + if (kanbanFilters.search !== taskToEdit.title) { + setKanbanFilters({ + ...kanbanFilters, + search: taskToEdit.title + }); + + // Nettoyer l'URL pour éviter les répétitions + if (typeof window !== 'undefined') { + const url = new URL(window.location.href); + url.searchParams.delete('taskId'); + window.history.replaceState({}, '', url.toString()); + } + } + }, [kanbanFilters, setKanbanFilters]); + + // Effet pour appliquer un filtre de recherche si un taskId est fourni dans l'URL useEffect(() => { if (initialTaskIdToEdit && filteredTasks.length > 0) { const taskToEdit = filteredTasks.find(task => task.id === initialTaskIdToEdit); if (taskToEdit) { - setEditingTask(taskToEdit); + applyTaskFilter(taskToEdit); } } - }, [initialTaskIdToEdit, filteredTasks]); + }, [initialTaskIdToEdit, filteredTasks, applyTaskFilter]); const handleEditTask = (task: Task) => { setEditingTask(task);