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.
This commit is contained in:
@@ -116,8 +116,19 @@ export function RecentTasks({ tasks }: RecentTasksProps) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="text-xs text-[var(--muted-foreground)] whitespace-nowrap">
|
||||
{formatDateShort(task.updatedAt)}
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="text-xs text-[var(--muted-foreground)] whitespace-nowrap">
|
||||
{formatDateShort(task.updatedAt)}
|
||||
</div>
|
||||
<Link
|
||||
href={`/kanban?taskId=${task.id}`}
|
||||
className="p-1 rounded hover:bg-[var(--muted)]/50 transition-colors"
|
||||
title="Ouvrir dans le Kanban"
|
||||
>
|
||||
<svg className="w-3 h-3 text-[var(--primary)] hover:text-[var(--primary)]/80" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
|
||||
</svg>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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<Task | null>(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);
|
||||
|
||||
Reference in New Issue
Block a user