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:
@@ -1,7 +1,7 @@
|
||||
'use server';
|
||||
|
||||
import { dailyService } from '@/services/daily';
|
||||
import { UpdateDailyCheckboxData, DailyCheckbox } from '@/lib/types';
|
||||
import { UpdateDailyCheckboxData, DailyCheckbox, CreateDailyCheckboxData } from '@/lib/types';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
|
||||
/**
|
||||
@@ -198,6 +198,40 @@ export async function deleteCheckbox(checkboxId: string): Promise<{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute un todo lié à une tâche
|
||||
*/
|
||||
export async function addTodoToTask(taskId: string, text: string, date?: Date): Promise<{
|
||||
success: boolean;
|
||||
data?: DailyCheckbox;
|
||||
error?: string;
|
||||
}> {
|
||||
try {
|
||||
const targetDate = date || new Date();
|
||||
targetDate.setHours(0, 0, 0, 0);
|
||||
|
||||
const checkboxData: CreateDailyCheckboxData = {
|
||||
date: targetDate,
|
||||
text: text.trim(),
|
||||
type: 'task',
|
||||
taskId: taskId,
|
||||
isChecked: false
|
||||
};
|
||||
|
||||
const checkbox = await dailyService.addCheckbox(checkboxData);
|
||||
|
||||
revalidatePath('/daily');
|
||||
revalidatePath('/kanban');
|
||||
return { success: true, data: checkbox };
|
||||
} catch (error) {
|
||||
console.error('Erreur addTodoToTask:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Erreur inconnue'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Réorganise les checkboxes d'une date
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user