From 742f436ff8ebe3c3e4a737924134f84a450df0b8 Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 13:29:53 +0200 Subject: [PATCH] working leantime widget 17 --- app/api/leantime/status-labels/route.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/api/leantime/status-labels/route.ts b/app/api/leantime/status-labels/route.ts index db6b87e7..16336d23 100644 --- a/app/api/leantime/status-labels/route.ts +++ b/app/api/leantime/status-labels/route.ts @@ -104,7 +104,7 @@ export async function GET() { } const data = await response.json(); - console.log('Tasks response:', data); + console.log('Tasks response:', JSON.stringify(data, null, 2)); if (!data.result) { return NextResponse.json({ tasks: [] }); @@ -129,6 +129,8 @@ export async function GET() { } const projectsData = await projectsResponse.json(); + console.log('Projects response:', JSON.stringify(projectsData, null, 2)); + const projectsMap = new Map( projectsData.result.map((project: any) => [project.id, project.name]) ); @@ -137,13 +139,18 @@ export async function GET() { const tasks: Task[] = []; Object.entries(data.result).forEach(([projectId, statusGroups]) => { const projectName = projectsMap.get(Number(projectId)) || `Project ${projectId}`; + console.log(`Processing project ${projectId} (${projectName}):`, JSON.stringify(statusGroups, null, 2)); if (typeof statusGroups === 'object' && statusGroups !== null) { // Iterate through each status group Object.entries(statusGroups).forEach(([statusType, statusLabels]) => { + console.log(` Status type ${statusType}:`, JSON.stringify(statusLabels, null, 2)); + if (typeof statusLabels === 'object' && statusLabels !== null) { // Each status label in the group Object.values(statusLabels).forEach((label: any) => { + console.log(` Processing label:`, JSON.stringify(label, null, 2)); + const headline = String(label.name || label.title || 'Untitled'); tasks.push({ id: label.id?.toString() || `${projectId}-${statusType}`, @@ -160,6 +167,8 @@ export async function GET() { } }); + console.log('Transformed tasks:', JSON.stringify(tasks, null, 2)); + // Sort tasks by status type const statusOrder: Record = { 'new': 1,