working leantime widget 17
This commit is contained in:
parent
0372dd7aed
commit
742f436ff8
@ -104,7 +104,7 @@ export async function GET() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log('Tasks response:', data);
|
console.log('Tasks response:', JSON.stringify(data, null, 2));
|
||||||
|
|
||||||
if (!data.result) {
|
if (!data.result) {
|
||||||
return NextResponse.json({ tasks: [] });
|
return NextResponse.json({ tasks: [] });
|
||||||
@ -129,6 +129,8 @@ export async function GET() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const projectsData = await projectsResponse.json();
|
const projectsData = await projectsResponse.json();
|
||||||
|
console.log('Projects response:', JSON.stringify(projectsData, null, 2));
|
||||||
|
|
||||||
const projectsMap = new Map(
|
const projectsMap = new Map(
|
||||||
projectsData.result.map((project: any) => [project.id, project.name])
|
projectsData.result.map((project: any) => [project.id, project.name])
|
||||||
);
|
);
|
||||||
@ -137,13 +139,18 @@ export async function GET() {
|
|||||||
const tasks: Task[] = [];
|
const tasks: Task[] = [];
|
||||||
Object.entries(data.result).forEach(([projectId, statusGroups]) => {
|
Object.entries(data.result).forEach(([projectId, statusGroups]) => {
|
||||||
const projectName = projectsMap.get(Number(projectId)) || `Project ${projectId}`;
|
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) {
|
if (typeof statusGroups === 'object' && statusGroups !== null) {
|
||||||
// Iterate through each status group
|
// Iterate through each status group
|
||||||
Object.entries(statusGroups).forEach(([statusType, statusLabels]) => {
|
Object.entries(statusGroups).forEach(([statusType, statusLabels]) => {
|
||||||
|
console.log(` Status type ${statusType}:`, JSON.stringify(statusLabels, null, 2));
|
||||||
|
|
||||||
if (typeof statusLabels === 'object' && statusLabels !== null) {
|
if (typeof statusLabels === 'object' && statusLabels !== null) {
|
||||||
// Each status label in the group
|
// Each status label in the group
|
||||||
Object.values(statusLabels).forEach((label: any) => {
|
Object.values(statusLabels).forEach((label: any) => {
|
||||||
|
console.log(` Processing label:`, JSON.stringify(label, null, 2));
|
||||||
|
|
||||||
const headline = String(label.name || label.title || 'Untitled');
|
const headline = String(label.name || label.title || 'Untitled');
|
||||||
tasks.push({
|
tasks.push({
|
||||||
id: label.id?.toString() || `${projectId}-${statusType}`,
|
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
|
// Sort tasks by status type
|
||||||
const statusOrder: Record<string, number> = {
|
const statusOrder: Record<string, number> = {
|
||||||
'new': 1,
|
'new': 1,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user