feat: extend task management with new statuses and centralized configuration
- Added `cancelled` and `freeze` statuses to `TasksResponse`, `HomePageClientProps`, and `useTasks` for comprehensive task tracking. - Updated task forms to dynamically load statuses using `getAllStatuses`, enhancing maintainability and reducing hardcoded values. - Refactored Kanban components to utilize centralized status configuration, improving consistency across the application. - Adjusted visibility toggle and swimlanes to reflect new status options, ensuring a seamless user experience.
This commit is contained in:
@@ -8,6 +8,7 @@ import { CreateTaskData } from '@/clients/tasks-client';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useColumnVisibility } from '@/hooks/useColumnVisibility';
|
||||
import { ColumnVisibilityToggle } from './ColumnVisibilityToggle';
|
||||
import { getAllStatuses } from '@/lib/status-config';
|
||||
import {
|
||||
DndContext,
|
||||
DragEndEvent,
|
||||
@@ -58,38 +59,13 @@ export function KanbanBoard({ tasks, onCreateTask, onDeleteTask, onEditTask, onU
|
||||
return grouped;
|
||||
}, [tasks]);
|
||||
|
||||
// Configuration des colonnes
|
||||
const allColumns: 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 || []
|
||||
}
|
||||
];
|
||||
// Configuration des colonnes basée sur la config centralisée
|
||||
const allColumns = useMemo(() => {
|
||||
return getAllStatuses().map(statusConfig => ({
|
||||
id: statusConfig.key,
|
||||
tasks: tasksByStatus[statusConfig.key] || []
|
||||
}));
|
||||
}, [tasksByStatus]);
|
||||
|
||||
// Filtrer les colonnes visibles
|
||||
const visibleColumns = getVisibleStatuses(allColumns);
|
||||
@@ -156,7 +132,6 @@ export function KanbanBoard({ tasks, onCreateTask, onDeleteTask, onEditTask, onU
|
||||
{/* Toggle de visibilité des colonnes */}
|
||||
<div className="px-6 pb-4">
|
||||
<ColumnVisibilityToggle
|
||||
statuses={allColumns}
|
||||
hiddenStatuses={hiddenStatuses}
|
||||
onToggleStatus={toggleStatusVisibility}
|
||||
/>
|
||||
@@ -168,8 +143,6 @@ export function KanbanBoard({ tasks, onCreateTask, onDeleteTask, onEditTask, onU
|
||||
<KanbanColumn
|
||||
key={column.id}
|
||||
id={column.id}
|
||||
title={column.title}
|
||||
color={column.color}
|
||||
tasks={column.tasks}
|
||||
onCreateTask={onCreateTask ? handleCreateTask : undefined}
|
||||
onDeleteTask={onDeleteTask}
|
||||
|
||||
Reference in New Issue
Block a user