duties widget correction

This commit is contained in:
Alma 2025-04-13 18:48:05 +02:00
parent aa0c41f1ea
commit 966dc18faf

View File

@ -152,8 +152,9 @@ export async function GET(request: NextRequest) {
const tasks = data.result const tasks = data.result
.filter((task: any) => { .filter((task: any) => {
// Skip completed tasks (status 5) // Skip all completed tasks (status 5), whether they are main tasks or subtasks
if (task.status === 5) { if (task.status === 5) {
console.log(`Filtering out completed task ${task.id} (type: ${task.type || 'main'})`);
return false; return false;
} }
@ -162,7 +163,9 @@ export async function GET(request: NextRequest) {
const currentUserId = String(userId).trim(); const currentUserId = String(userId).trim();
// Only show tasks where the user is the editor // Only show tasks where the user is the editor
return taskEditorId === currentUserId; const isUserEditor = taskEditorId === currentUserId;
console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, isUserEditor=${isUserEditor}`);
return isUserEditor;
}) })
.map((task: any) => ({ .map((task: any) => ({
id: task.id.toString(), id: task.id.toString(),
@ -177,7 +180,8 @@ export async function GET(request: NextRequest) {
editedOn: task.editedOn || null, editedOn: task.editedOn || null,
editorId: task.editorId, editorId: task.editorId,
editorFirstname: task.editorFirstname, editorFirstname: task.editorFirstname,
editorLastname: task.editorLastname editorLastname: task.editorLastname,
type: task.type || null // Added type field to identify subtasks
})); }));
console.log(`Found ${tasks.length} tasks assigned to user ${userId}`); console.log(`Found ${tasks.length} tasks assigned to user ${userId}`);