- Implemented `RelatedTodos` component in `EditTaskForm` to display and manage related todos for a task. - Updated `TasksClient` to fetch daily checkboxes related to a task. - Enhanced `TasksService` with a method to retrieve related daily checkboxes from the database. - Added functionality to create new todos linked to tasks in the daily actions. - Marked the task for displaying related todos in the task editing interface as complete in TODO.md.
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();
|