duties widget correction 4
This commit is contained in:
parent
1e01d2e356
commit
fba4b1754b
@ -152,19 +152,28 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
const tasks = data.result
|
const tasks = data.result
|
||||||
.filter((task: any) => {
|
.filter((task: any) => {
|
||||||
// Skip all completed tasks (status 5), whether they are main tasks or subtasks
|
// Skip all completed tasks (status 5)
|
||||||
if (task.status === 5) {
|
if (task.status === 5) {
|
||||||
console.log(`Filtering out completed task ${task.id} (type: ${task.type || 'main'})`);
|
console.log(`Filtering out completed task ${task.id} (type: ${task.type || 'main'})`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For subtasks, check if parent task is completed
|
||||||
|
if (task.type === 'subtask' && task.dependingTicketId) {
|
||||||
|
const parentTask = data.result.find((t: any) => t.id === task.dependingTicketId);
|
||||||
|
if (parentTask && parentTask.status === 5) {
|
||||||
|
console.log(`Filtering out subtask ${task.id} because parent task ${task.dependingTicketId} is completed`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Convert both to strings for comparison to handle any type mismatches
|
// Convert both to strings for comparison to handle any type mismatches
|
||||||
const taskEditorId = String(task.editorId).trim();
|
const taskEditorId = String(task.editorId).trim();
|
||||||
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
|
||||||
const isUserEditor = taskEditorId === currentUserId;
|
const isUserEditor = taskEditorId === currentUserId;
|
||||||
console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, isUserEditor=${isUserEditor}`);
|
console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, parentId=${task.dependingTicketId || 'none'}, isUserEditor=${isUserEditor}`);
|
||||||
return isUserEditor;
|
return isUserEditor;
|
||||||
})
|
})
|
||||||
.map((task: any) => ({
|
.map((task: any) => ({
|
||||||
@ -181,7 +190,8 @@ export async function GET(request: NextRequest) {
|
|||||||
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
|
type: task.type || null, // Added type field to identify subtasks
|
||||||
|
dependingTicketId: task.dependingTicketId || null // Added parent task reference
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log(`Found ${tasks.length} tasks assigned to user ${userId}`);
|
console.log(`Found ${tasks.length} tasks assigned to user ${userId}`);
|
||||||
|
|||||||
@ -23,6 +23,7 @@ interface Task {
|
|||||||
editTo?: string;
|
editTo?: string;
|
||||||
editFrom?: string;
|
editFrom?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
|
dependingTicketId?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProjectSummary {
|
interface ProjectSummary {
|
||||||
@ -110,7 +111,7 @@ export function Duties() {
|
|||||||
.filter((task: Task) => {
|
.filter((task: Task) => {
|
||||||
const isNotDone = task.status !== 5;
|
const isNotDone = task.status !== 5;
|
||||||
// Log task details for debugging
|
// Log task details for debugging
|
||||||
console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, dateToFinish=${task.dateToFinish}, isNotDone=${isNotDone}`);
|
console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, parentId=${task.dependingTicketId || 'none'}, dateToFinish=${task.dateToFinish}, isNotDone=${isNotDone}`);
|
||||||
return isNotDone;
|
return isNotDone;
|
||||||
})
|
})
|
||||||
.sort((a: Task, b: Task) => {
|
.sort((a: Task, b: Task) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user