- Updated `TODO.md` to reflect new testing tasks and final structure expectations. - Simplified TypeScript path mappings in `tsconfig.json` for better clarity. - Revised business logic separation rules in `.cursor/rules` to align with new directory structure. - Deleted unused client components and services to streamline the codebase. - Adjusted import paths in scripts to match the new structure.
82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
import { httpClient } from './base/http-client';
|
|
import { Task, TaskStatus, TaskPriority, TaskStats, DailyCheckbox } from '@/lib/types';
|
|
|
|
export interface TaskFilters {
|
|
status?: TaskStatus[];
|
|
source?: string[];
|
|
search?: string;
|
|
limit?: number;
|
|
offset?: number;
|
|
}
|
|
|
|
export interface TasksResponse {
|
|
success: boolean;
|
|
data: Task[];
|
|
stats: TaskStats;
|
|
count: number;
|
|
}
|
|
|
|
export interface CreateTaskData {
|
|
title: string;
|
|
description?: string;
|
|
status?: TaskStatus;
|
|
priority?: TaskPriority;
|
|
tags?: string[];
|
|
dueDate?: Date;
|
|
}
|
|
|
|
export interface UpdateTaskData {
|
|
taskId: string;
|
|
title?: string;
|
|
description?: string;
|
|
status?: TaskStatus;
|
|
priority?: TaskPriority;
|
|
tags?: string[];
|
|
dueDate?: Date;
|
|
}
|
|
|
|
/**
|
|
* Client pour la gestion des tâches
|
|
*/
|
|
export class TasksClient {
|
|
|
|
/**
|
|
* Récupère toutes les tâches avec filtres
|
|
*/
|
|
async getTasks(filters?: TaskFilters): Promise<TasksResponse> {
|
|
const params: Record<string, string> = {};
|
|
|
|
if (filters?.status) {
|
|
params.status = filters.status.join(',');
|
|
}
|
|
if (filters?.source) {
|
|
params.source = filters.source.join(',');
|
|
}
|
|
if (filters?.search) {
|
|
params.search = filters.search;
|
|
}
|
|
if (filters?.limit) {
|
|
params.limit = filters.limit.toString();
|
|
}
|
|
if (filters?.offset) {
|
|
params.offset = filters.offset.toString();
|
|
}
|
|
|
|
return httpClient.get<TasksResponse>('/tasks', params);
|
|
}
|
|
|
|
/**
|
|
* Récupère les daily checkboxes liées à une tâche
|
|
*/
|
|
async getTaskCheckboxes(taskId: string): Promise<DailyCheckbox[]> {
|
|
const response = await httpClient.get<{ data: DailyCheckbox[] }>(`/tasks/${taskId}/checkboxes`);
|
|
return response.data;
|
|
}
|
|
|
|
// Note: Les méthodes createTask, updateTask et deleteTask ont été migrées vers Server Actions
|
|
// Voir /src/actions/tasks.ts pour createTask, updateTask, updateTaskTitle, updateTaskStatus, deleteTask
|
|
}
|
|
|
|
// Instance singleton
|
|
export const tasksClient = new TasksClient();
|