diff --git a/app/api/leantime/tasks/route.ts b/app/api/leantime/tasks/route.ts index 5cff97f8..453ae21b 100644 --- a/app/api/leantime/tasks/route.ts +++ b/app/api/leantime/tasks/route.ts @@ -169,14 +169,14 @@ export async function GET(request: NextRequest) { const taskEditorId = String(task.editorId).trim(); const currentUserId = String(userId).trim(); - // Check if the user is the editor or if editorId is empty (unassigned) - const isEditor = taskEditorId === currentUserId || taskEditorId === ''; - - // Also check if the user is in the assignedTo array if it exists - const isAssignedToUser = Array.isArray(task.assignedTo) && - task.assignedTo.some((id: any) => String(id).trim() === currentUserId); - - return isEditor || isAssignedToUser; + // Show tasks where: + // 1. The user is the editor + // 2. The task is unassigned (empty editorId) + // 3. The user is in the assignedTo array + return taskEditorId === currentUserId || + taskEditorId === '' || + (Array.isArray(task.assignedTo) && + task.assignedTo.some((id: any) => String(id).trim() === currentUserId)); }) .map((task: any) => ({ id: task.id.toString(), diff --git a/components/flow.tsx b/components/flow.tsx index 870d41be..36962b9b 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -89,15 +89,37 @@ export function Flow() { .filter((task: Task) => task.headline && typeof task.headline === 'string' && - task.status !== 5 // Not done + task.status !== 3 // Not completed ) .sort((a: Task, b: Task) => { - // First sort by status (new tasks first) + // Define priority order for tasks + const priorityOrder = [ + 'Mettre en ligne site wix SLM-SA', + 'Bi-Dimension Investment', + 'Draft Pax Index Mvt 4 CARE', + 'Finaliser Pax Index Mvt 5 Data Intelligence Governance DIG', + 'Continuous Improving Cycle : Risk Monitoring + Model Assessments + Learning Machine', + 'Rediger pétition ODD18 et intégration au site CLM', + 'complete ressources background and quote' + ]; + + const aIndex = priorityOrder.indexOf(a.headline); + const bIndex = priorityOrder.indexOf(b.headline); + + // If both tasks are in the priority list, sort by their position + if (aIndex !== -1 && bIndex !== -1) { + return aIndex - bIndex; + } + + // If only one task is in the priority list, it comes first + if (aIndex !== -1) return -1; + if (bIndex !== -1) return 1; + + // For tasks not in the priority list, sort by status and date if (a.status !== b.status) { return a.status - b.status; } - // Then sort by due date const dateA = a.dateToFinish && a.dateToFinish !== '0000-00-00 00:00:00' ? new Date(a.dateToFinish).getTime() : Number.MAX_SAFE_INTEGER; @@ -109,7 +131,7 @@ export function Flow() { }); console.log('Filtered and sorted tasks:', sortedTasks); - setTasks(sortedTasks.slice(0, 6)); + setTasks(sortedTasks); // Remove the slice(0, 6) to show all tasks setError(null); } catch (err) { console.error('Error fetching tasks:', err);