feat: add related todos functionality in task editing

- 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.
This commit is contained in:
Julien Froidefond
2025-09-18 15:26:07 +02:00
parent 729a04d557
commit 02f59caf08
7 changed files with 345 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import { prisma } from './database';
import { Task, TaskStatus, TaskPriority, TaskSource, BusinessError } from '@/lib/types';
import { Task, TaskStatus, TaskPriority, TaskSource, BusinessError, DailyCheckbox, DailyCheckboxType } from '@/lib/types';
import { Prisma } from '@prisma/client';
/**
@@ -185,6 +185,50 @@ export class TasksService {
return this.updateTask(taskId, { status: newStatus });
}
/**
* Récupère les daily checkboxes liées à une tâche
*/
async getTaskRelatedCheckboxes(taskId: string): Promise<DailyCheckbox[]> {
const checkboxes = await prisma.dailyCheckbox.findMany({
where: { taskId: taskId },
include: { task: true },
orderBy: [
{ date: 'desc' },
{ order: 'asc' }
]
});
return checkboxes.map(checkbox => ({
id: checkbox.id,
date: checkbox.date,
text: checkbox.text,
isChecked: checkbox.isChecked,
type: checkbox.type as DailyCheckboxType,
order: checkbox.order,
taskId: checkbox.taskId ?? undefined,
task: checkbox.task ? {
id: checkbox.task.id,
title: checkbox.task.title,
description: checkbox.task.description ?? undefined,
status: checkbox.task.status as TaskStatus,
priority: checkbox.task.priority as TaskPriority,
source: checkbox.task.source as TaskSource,
sourceId: checkbox.task.sourceId ?? undefined,
tags: [], // Les tags ne sont pas nécessaires dans ce contexte
dueDate: checkbox.task.dueDate ?? undefined,
completedAt: checkbox.task.completedAt ?? undefined,
createdAt: checkbox.task.createdAt,
updatedAt: checkbox.task.updatedAt,
jiraProject: checkbox.task.jiraProject ?? undefined,
jiraKey: checkbox.task.jiraKey ?? undefined,
jiraType: checkbox.task.jiraType ?? undefined,
assignee: checkbox.task.assignee ?? undefined
} : undefined,
createdAt: checkbox.createdAt,
updatedAt: checkbox.updatedAt
}));
}
/**
* Récupère les statistiques des tâches
*/