feat: enhance task filtering in EditCheckboxModal
- Updated `filteredTasks` logic to exclude tasks marked as "objectif principal" (isPinned = true) for better task management. - Added `tagDetails` property to `Task` interface to store detailed tag information, improving task data structure. - Adjusted `TasksService` to extract and include tag details when retrieving tasks from the database.
This commit is contained in:
@@ -58,11 +58,17 @@ export function EditCheckboxModal({
|
||||
}
|
||||
}, [taskId, allTasks]);
|
||||
|
||||
// Filtrer les tâches selon la recherche
|
||||
const filteredTasks = allTasks.filter(task =>
|
||||
task.title.toLowerCase().includes(taskSearch.toLowerCase()) ||
|
||||
(task.description && task.description.toLowerCase().includes(taskSearch.toLowerCase()))
|
||||
);
|
||||
// Filtrer les tâches selon la recherche et exclure les tâches avec des tags "objectif principal"
|
||||
const filteredTasks = allTasks.filter(task => {
|
||||
// Exclure les tâches avec des tags marqués comme "objectif principal" (isPinned = true)
|
||||
if (task.tagDetails && task.tagDetails.some(tag => tag.isPinned)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Filtrer selon la recherche
|
||||
return task.title.toLowerCase().includes(taskSearch.toLowerCase()) ||
|
||||
(task.description && task.description.toLowerCase().includes(taskSearch.toLowerCase()));
|
||||
});
|
||||
|
||||
const handleTaskSelect = (task: Task) => {
|
||||
setTaskId(task.id);
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface Task {
|
||||
source: TaskSource;
|
||||
sourceId?: string;
|
||||
tags: string[];
|
||||
tagDetails?: Tag[]; // Tags avec informations complètes (isPinned, etc.)
|
||||
dueDate?: Date;
|
||||
completedAt?: Date;
|
||||
createdAt: Date;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { prisma } from '@/services/core/database';
|
||||
import { Task, TaskStatus, TaskPriority, TaskSource, BusinessError, DailyCheckbox, DailyCheckboxType } from '@/lib/types';
|
||||
import { Task, TaskStatus, TaskPriority, TaskSource, BusinessError, DailyCheckbox, DailyCheckboxType, Tag } from '@/lib/types';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { getToday } from '@/lib/date-utils';
|
||||
|
||||
@@ -358,12 +358,19 @@ export class TasksService {
|
||||
}
|
||||
}
|
||||
}> | Prisma.TaskGetPayload<object>): Task {
|
||||
// Extraire les tags depuis les relations TaskTag ou fallback sur tagsJson
|
||||
// Extraire les tags depuis les relations TaskTag
|
||||
let tags: string[] = [];
|
||||
let tagDetails: Tag[] = [];
|
||||
|
||||
if ('taskTags' in prismaTask && prismaTask.taskTags && Array.isArray(prismaTask.taskTags)) {
|
||||
// Utiliser les relations Prisma
|
||||
// Utiliser les relations Prisma pour récupérer les noms et détails des tags
|
||||
tags = prismaTask.taskTags.map((tt) => tt.tag.name);
|
||||
tagDetails = prismaTask.taskTags.map((tt) => ({
|
||||
id: tt.tag.id,
|
||||
name: tt.tag.name,
|
||||
color: tt.tag.color,
|
||||
isPinned: tt.tag.isPinned
|
||||
}));
|
||||
}
|
||||
|
||||
// Extraire le count des todos
|
||||
@@ -381,6 +388,7 @@ export class TasksService {
|
||||
source: prismaTask.source as TaskSource,
|
||||
sourceId: prismaTask.sourceId ?? undefined,
|
||||
tags: tags,
|
||||
tagDetails: tagDetails,
|
||||
dueDate: prismaTask.dueDate ?? undefined,
|
||||
completedAt: prismaTask.completedAt ?? undefined,
|
||||
createdAt: prismaTask.createdAt,
|
||||
|
||||
Reference in New Issue
Block a user