feat(DailyService): implement toggleCheckbox method for direct checkbox state updates

This commit is contained in:
Julien Froidefond
2025-10-30 08:15:01 +01:00
parent cd391506ce
commit 0bf9802e71
3 changed files with 44 additions and 28 deletions

View File

@@ -130,6 +130,27 @@ export class DailyService {
return this.mapPrismaCheckbox(checkbox);
}
/**
* Toggle l'état d'une checkbox par son ID (indépendant de la date)
*/
async toggleCheckbox(checkboxId: string): Promise<DailyCheckbox> {
const existing = await prisma.dailyCheckbox.findUnique({
where: { id: checkboxId },
});
if (!existing) {
throw new BusinessError('Checkbox non trouvée');
}
const updated = await prisma.dailyCheckbox.update({
where: { id: checkboxId },
data: { isChecked: !existing.isChecked, updatedAt: new Date() },
include: { task: true, user: true },
});
return this.mapPrismaCheckbox(updated);
}
/**
* Supprime une checkbox
*/