feat: implement drag & drop functionality using @dnd-kit
- Added drag & drop capabilities to the Kanban board with @dnd-kit for task status updates. - Integrated DndContext in `KanbanBoard` and utilized `useDroppable` in `KanbanColumn` for drop zones. - Enhanced `TaskCard` with draggable features and visual feedback during dragging. - Updated `TODO.md` to reflect the completion of drag & drop tasks and optimistically update task statuses. - Introduced optimistic updates in `useTasks` for smoother user experience during drag & drop operations.
This commit is contained in:
@@ -4,7 +4,7 @@ import { useState } from 'react';
|
||||
import { KanbanBoard } from './Board';
|
||||
import { EditTaskForm } from '@/components/forms/EditTaskForm';
|
||||
import { useTasks } from '@/hooks/useTasks';
|
||||
import { Task } from '@/lib/types';
|
||||
import { Task, TaskStatus } from '@/lib/types';
|
||||
import { UpdateTaskData } from '@/clients/tasks-client';
|
||||
|
||||
interface BoardContainerProps {
|
||||
@@ -19,7 +19,7 @@ interface BoardContainerProps {
|
||||
}
|
||||
|
||||
export function KanbanBoardContainer({ initialTasks, initialStats }: BoardContainerProps) {
|
||||
const { tasks, loading, createTask, deleteTask, updateTask } = useTasks(
|
||||
const { tasks, loading, syncing, createTask, deleteTask, updateTask, updateTaskOptimistic } = useTasks(
|
||||
{ limit: 20 },
|
||||
{ tasks: initialTasks, stats: initialStats }
|
||||
);
|
||||
@@ -42,6 +42,14 @@ export function KanbanBoardContainer({ initialTasks, initialStats }: BoardContai
|
||||
});
|
||||
};
|
||||
|
||||
const handleUpdateStatus = async (taskId: string, newStatus: TaskStatus) => {
|
||||
// Utiliser la mise à jour optimiste pour le drag & drop
|
||||
await updateTaskOptimistic({
|
||||
taskId,
|
||||
status: newStatus
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<KanbanBoard
|
||||
@@ -50,6 +58,7 @@ export function KanbanBoardContainer({ initialTasks, initialStats }: BoardContai
|
||||
onDeleteTask={deleteTask}
|
||||
onEditTask={handleEditTask}
|
||||
onUpdateTitle={handleUpdateTitle}
|
||||
onUpdateStatus={handleUpdateStatus}
|
||||
loading={loading}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user