feat: overhaul TODO.md and enhance Kanban components
- Updated TODO.md to reflect the new project structure and phases, marking several tasks as completed. - Enhanced Kanban components with a tech-inspired design, including new styles for columns and task cards. - Removed the obsolete reminders service and task processor, streamlining the codebase for better maintainability. - Introduced a modern API for task management, including CRUD operations and improved error handling. - Updated global styles for a cohesive dark theme and added custom scrollbar styles.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { taskProcessorService } from '@/services/task-processor';
|
||||
import { TaskStatus } from '@/lib/types';
|
||||
import { tasksService } from '@/services/tasks';
|
||||
import { TaskStatus, TaskPriority } from '@/lib/types';
|
||||
|
||||
/**
|
||||
* API route pour récupérer les tâches avec filtres optionnels
|
||||
@@ -10,7 +10,13 @@ export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
// Extraire les paramètres de filtre
|
||||
const filters: any = {};
|
||||
const filters: {
|
||||
status?: TaskStatus[];
|
||||
source?: string[];
|
||||
search?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
} = {};
|
||||
|
||||
const status = searchParams.get('status');
|
||||
if (status) {
|
||||
@@ -38,8 +44,8 @@ export async function GET(request: Request) {
|
||||
}
|
||||
|
||||
// Récupérer les tâches
|
||||
const tasks = await taskProcessorService.getTasks(filters);
|
||||
const stats = await taskProcessorService.getTaskStats();
|
||||
const tasks = await tasksService.getTasks(filters);
|
||||
const stats = await tasksService.getTaskStats();
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
@@ -60,26 +66,71 @@ export async function GET(request: Request) {
|
||||
}
|
||||
|
||||
/**
|
||||
* API route pour mettre à jour le statut d'une tâche
|
||||
* API route pour créer une nouvelle tâche
|
||||
*/
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { title, description, status, priority, tags, dueDate } = body;
|
||||
|
||||
if (!title) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: 'Le titre est requis'
|
||||
}, { status: 400 });
|
||||
}
|
||||
|
||||
const task = await tasksService.createTask({
|
||||
title,
|
||||
description,
|
||||
status: status as TaskStatus,
|
||||
priority: priority as TaskPriority,
|
||||
tags,
|
||||
dueDate: dueDate ? new Date(dueDate) : undefined
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: task,
|
||||
message: 'Tâche créée avec succès'
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur lors de la création de la tâche:', error);
|
||||
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Erreur inconnue'
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API route pour mettre à jour une tâche
|
||||
*/
|
||||
export async function PATCH(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { taskId, status } = body;
|
||||
const { taskId, ...updates } = body;
|
||||
|
||||
if (!taskId || !status) {
|
||||
if (!taskId) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: 'taskId et status sont requis'
|
||||
error: 'taskId est requis'
|
||||
}, { status: 400 });
|
||||
}
|
||||
|
||||
const updatedTask = await taskProcessorService.updateTaskStatus(taskId, status);
|
||||
// Convertir dueDate si présent
|
||||
if (updates.dueDate) {
|
||||
updates.dueDate = new Date(updates.dueDate);
|
||||
}
|
||||
|
||||
const updatedTask = await tasksService.updateTask(taskId, updates);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: updatedTask,
|
||||
message: `Tâche ${taskId} mise à jour avec le statut ${status}`
|
||||
message: 'Tâche mise à jour avec succès'
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
@@ -91,3 +142,35 @@ export async function PATCH(request: Request) {
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API route pour supprimer une tâche
|
||||
*/
|
||||
export async function DELETE(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const taskId = searchParams.get('taskId');
|
||||
|
||||
if (!taskId) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: 'taskId est requis'
|
||||
}, { status: 400 });
|
||||
}
|
||||
|
||||
await tasksService.deleteTask(taskId);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Tâche supprimée avec succès'
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur lors de la suppression de la tâche:', error);
|
||||
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Erreur inconnue'
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user