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:
@@ -1,8 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Header } from './Header';
|
||||
import { tasksClient } from '@/clients/tasks-client';
|
||||
import { useTasks } from '@/hooks/useTasks';
|
||||
|
||||
interface HeaderContainerProps {
|
||||
title: string;
|
||||
@@ -17,41 +16,17 @@ interface HeaderContainerProps {
|
||||
}
|
||||
|
||||
export function HeaderContainer({ title, subtitle, initialStats }: HeaderContainerProps) {
|
||||
const [stats, setStats] = useState(initialStats);
|
||||
const [isHydrated, setIsHydrated] = useState(false);
|
||||
|
||||
// Hydratation côté client
|
||||
useEffect(() => {
|
||||
setIsHydrated(true);
|
||||
}, []);
|
||||
|
||||
// Rafraîchir les stats périodiquement côté client
|
||||
useEffect(() => {
|
||||
if (!isHydrated) return;
|
||||
|
||||
const refreshStats = async () => {
|
||||
try {
|
||||
const response = await tasksClient.getTasks({ limit: 1 }); // Juste pour les stats
|
||||
setStats(response.stats);
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du rafraîchissement des stats:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Rafraîchir les stats toutes les 30 secondes
|
||||
const interval = setInterval(refreshStats, 30000);
|
||||
|
||||
// Rafraîchir immédiatement après hydratation
|
||||
refreshStats();
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [isHydrated]);
|
||||
const { stats, syncing } = useTasks(
|
||||
{ limit: 1 }, // Juste pour les stats
|
||||
{ tasks: [], stats: initialStats }
|
||||
);
|
||||
|
||||
return (
|
||||
<Header
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
stats={stats}
|
||||
syncing={syncing}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user