feat: add date-fns dependency and update HomePage component
- Added `date-fns` as a dependency in `package.json` and `package-lock.json`. - Refactored `Home` component to `HomePage`, implementing server-side rendering for tasks and stats retrieval. - Integrated `Header` and `KanbanBoard` components for improved UI structure. - Marked Kanban components as completed in `TODO.md`.
This commit is contained in:
71
components/kanban/Board.tsx
Normal file
71
components/kanban/Board.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
'use client';
|
||||
|
||||
import { Task, TaskStatus } from '@/lib/types';
|
||||
import { KanbanColumn } from './Column';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
interface KanbanBoardProps {
|
||||
tasks: Task[];
|
||||
}
|
||||
|
||||
export function KanbanBoard({ tasks }: KanbanBoardProps) {
|
||||
// Organiser les tâches par statut
|
||||
const tasksByStatus = useMemo(() => {
|
||||
const grouped = tasks.reduce((acc, task) => {
|
||||
if (!acc[task.status]) {
|
||||
acc[task.status] = [];
|
||||
}
|
||||
acc[task.status].push(task);
|
||||
return acc;
|
||||
}, {} as Record<TaskStatus, Task[]>);
|
||||
|
||||
return grouped;
|
||||
}, [tasks]);
|
||||
|
||||
// Configuration des colonnes
|
||||
const columns: Array<{
|
||||
id: TaskStatus;
|
||||
title: string;
|
||||
color: string;
|
||||
tasks: Task[];
|
||||
}> = [
|
||||
{
|
||||
id: 'todo',
|
||||
title: 'À faire',
|
||||
color: 'gray',
|
||||
tasks: tasksByStatus.todo || []
|
||||
},
|
||||
{
|
||||
id: 'in_progress',
|
||||
title: 'En cours',
|
||||
color: 'blue',
|
||||
tasks: tasksByStatus.in_progress || []
|
||||
},
|
||||
{
|
||||
id: 'done',
|
||||
title: 'Terminé',
|
||||
color: 'green',
|
||||
tasks: tasksByStatus.done || []
|
||||
},
|
||||
{
|
||||
id: 'cancelled',
|
||||
title: 'Annulé',
|
||||
color: 'red',
|
||||
tasks: tasksByStatus.cancelled || []
|
||||
}
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="flex gap-6 overflow-x-auto pb-6">
|
||||
{columns.map((column) => (
|
||||
<KanbanColumn
|
||||
key={column.id}
|
||||
id={column.id}
|
||||
title={column.title}
|
||||
color={column.color}
|
||||
tasks={column.tasks}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user