feat: complete integration of macOS reminders with filtering and logging
- Marked tasks in TODO.md as completed for macOS reminders integration. - Enhanced RemindersService to filter reminders based on enabled lists and added detailed logging for better debugging. - Implemented methods for retrieving reminders from specific lists and parsing output from AppleScript.
This commit is contained in:
93
src/app/api/tasks/route.ts
Normal file
93
src/app/api/tasks/route.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { taskProcessorService } from '@/services/task-processor';
|
||||
import { TaskStatus } from '@/lib/types';
|
||||
|
||||
/**
|
||||
* API route pour récupérer les tâches avec filtres optionnels
|
||||
*/
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
|
||||
// Extraire les paramètres de filtre
|
||||
const filters: any = {};
|
||||
|
||||
const status = searchParams.get('status');
|
||||
if (status) {
|
||||
filters.status = status.split(',') as TaskStatus[];
|
||||
}
|
||||
|
||||
const source = searchParams.get('source');
|
||||
if (source) {
|
||||
filters.source = source.split(',');
|
||||
}
|
||||
|
||||
const search = searchParams.get('search');
|
||||
if (search) {
|
||||
filters.search = search;
|
||||
}
|
||||
|
||||
const limit = searchParams.get('limit');
|
||||
if (limit) {
|
||||
filters.limit = parseInt(limit);
|
||||
}
|
||||
|
||||
const offset = searchParams.get('offset');
|
||||
if (offset) {
|
||||
filters.offset = parseInt(offset);
|
||||
}
|
||||
|
||||
// Récupérer les tâches
|
||||
const tasks = await taskProcessorService.getTasks(filters);
|
||||
const stats = await taskProcessorService.getTaskStats();
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: tasks,
|
||||
stats,
|
||||
filters: filters,
|
||||
count: tasks.length
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur lors de la récupération des tâches:', error);
|
||||
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Erreur inconnue'
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API route pour mettre à jour le statut d'une tâche
|
||||
*/
|
||||
export async function PATCH(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { taskId, status } = body;
|
||||
|
||||
if (!taskId || !status) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: 'taskId et status sont requis'
|
||||
}, { status: 400 });
|
||||
}
|
||||
|
||||
const updatedTask = await taskProcessorService.updateTaskStatus(taskId, status);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: updatedTask,
|
||||
message: `Tâche ${taskId} mise à jour avec le statut ${status}`
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur lors de la mise à jour 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