working leantime widget 66
This commit is contained in:
parent
b30e2a95dd
commit
5a59f124e2
@ -13,7 +13,9 @@ interface Task {
|
||||
details: string | null;
|
||||
createdOn: string;
|
||||
editedOn: string | null;
|
||||
assignedTo: number[];
|
||||
editorId: string;
|
||||
editorFirstname: string;
|
||||
editorLastname: string;
|
||||
}
|
||||
|
||||
async function getLeantimeUserId(email: string): Promise<number | null> {
|
||||
@ -152,8 +154,10 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
const tasks = data.result
|
||||
.filter((task: any) =>
|
||||
// Only include tasks assigned to the user
|
||||
Array.isArray(task.assignedTo) && task.assignedTo.includes(userId)
|
||||
// Include tasks where the user is the editor
|
||||
task.editorId === userId.toString() ||
|
||||
// Or tasks explicitly assigned to the user (if assignedTo exists)
|
||||
(Array.isArray(task.assignedTo) && task.assignedTo.includes(userId))
|
||||
)
|
||||
.map((task: any) => ({
|
||||
id: task.id.toString(),
|
||||
@ -166,7 +170,9 @@ export async function GET(request: NextRequest) {
|
||||
details: task.description || null,
|
||||
createdOn: task.dateCreated,
|
||||
editedOn: task.editedOn || null,
|
||||
assignedTo: Array.isArray(task.assignedTo) ? task.assignedTo : []
|
||||
editorId: task.editorId,
|
||||
editorFirstname: task.editorFirstname,
|
||||
editorLastname: task.editorLastname
|
||||
}));
|
||||
|
||||
// Sort tasks by creation date (oldest first)
|
||||
|
||||
@ -15,7 +15,6 @@ interface Task {
|
||||
projectName: string;
|
||||
type: string;
|
||||
status: number;
|
||||
assignedTo: number[];
|
||||
editorId: string;
|
||||
editorFirstname: string | null;
|
||||
editorLastname: string | null;
|
||||
@ -103,8 +102,7 @@ export function Flow() {
|
||||
.filter((task: Task) =>
|
||||
task.headline &&
|
||||
typeof task.headline === 'string' &&
|
||||
task.status !== 5 && // Not done
|
||||
Array.isArray(task.assignedTo) && task.assignedTo.length > 0 // Has assignments
|
||||
task.status !== 5 // Not done
|
||||
)
|
||||
.sort((a: Task, b: Task) => {
|
||||
// First sort by status (new tasks first)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user