Widget Devoir Finition

This commit is contained in:
alma 2026-01-24 13:09:56 +01:00
parent 245c9c97ee
commit f0c5ef2be3

View File

@ -157,31 +157,64 @@ export function Duties() {
const leantimeStatusDetails = leantimeTasks.map((t: Task) => {
const rawStatus = (t as any).status;
const statusNum = typeof rawStatus === 'string' ? parseInt(rawStatus, 10) : rawStatus;
const isDone = statusNum === 5 || (typeof rawStatus === 'string' && rawStatus.toLowerCase() === 'done');
const statusStr = typeof rawStatus === 'string' ? rawStatus.toLowerCase().trim() : String(rawStatus).toLowerCase().trim();
const isDone = statusNum === 5 || statusStr === '5' || statusStr === 'done';
return {
id: t.id,
headline: t.headline,
status: rawStatus,
statusType: typeof rawStatus,
statusNum,
statusStr,
isDone,
};
});
const doneTasksCount = leantimeStatusDetails.filter(t => t.isDone).length;
if (doneTasksCount > 0) {
console.warn('[Devoirs Widget] ⚠️ Found done tasks in Leantime data:', {
// Group by status for better visibility
const statusGroups = leantimeStatusDetails.reduce((acc: any, t) => {
const key = String(t.status);
if (!acc[key]) {
acc[key] = { status: t.status, count: 0, tasks: [] };
}
acc[key].count++;
if (acc[key].tasks.length < 3) {
acc[key].tasks.push({ id: t.id, headline: t.headline });
}
return acc;
}, {});
const doneTasks = leantimeStatusDetails.filter(t => t.isDone);
// Always log status breakdown for debugging
console.log('[Devoirs Widget] 📊 Status Breakdown:', {
totalTasks: leantimeTasks.length,
statusGroups: Object.keys(statusGroups).map(key => ({
status: key,
count: statusGroups[key].count,
sample: statusGroups[key].tasks,
})),
doneTasksCount: doneTasks.length,
});
if (doneTasks.length > 0) {
console.error('[Devoirs Widget] ❌❌❌ FOUND DONE TASKS - THEY SHOULD BE FILTERED ❌❌❌', {
total: leantimeTasks.length,
doneCount: doneTasksCount,
doneTasks: leantimeStatusDetails.filter(t => t.isDone),
doneCount: doneTasks.length,
doneTasks: doneTasks.map(t => ({
id: t.id,
headline: t.headline,
status: t.status,
statusType: t.statusType,
statusNum: t.statusNum,
statusStr: t.statusStr,
})),
});
}
console.log('Combined tasks:', {
console.log('[Devoirs Widget] Combined tasks:', {
leantime: leantimeTasks.length,
twentyCrm: twentyCrmTasks.length,
total: allTasks.length,
leantimeStatuses: leantimeStatusDetails,
});
if (allTasks.length === 0) {