working leantime widget 54
This commit is contained in:
parent
eb09ffbaf5
commit
1a41f773eb
@ -12,7 +12,13 @@ interface Task {
|
|||||||
projectId: number;
|
projectId: number;
|
||||||
status: number;
|
status: number;
|
||||||
type: string;
|
type: string;
|
||||||
dateToFinish: string | null;
|
dateToFinish: string;
|
||||||
|
date: string;
|
||||||
|
editFrom: string;
|
||||||
|
editTo: string;
|
||||||
|
authorFirstname?: string;
|
||||||
|
authorLastname?: string;
|
||||||
|
tags?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProjectSummary {
|
interface ProjectSummary {
|
||||||
@ -58,6 +64,18 @@ export function Flow() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getDateToSort = (task: Task): number => {
|
||||||
|
// Try different date fields in order of preference
|
||||||
|
const dates = [
|
||||||
|
task.date,
|
||||||
|
task.dateToFinish,
|
||||||
|
task.editFrom,
|
||||||
|
task.editTo
|
||||||
|
].filter(date => date && date !== '0000-00-00 00:00:00');
|
||||||
|
|
||||||
|
return dates.length > 0 ? new Date(dates[0]).getTime() : 0;
|
||||||
|
};
|
||||||
|
|
||||||
const fetchTasks = async (isRefresh = false) => {
|
const fetchTasks = async (isRefresh = false) => {
|
||||||
try {
|
try {
|
||||||
if (isRefresh) setRefreshing(true);
|
if (isRefresh) setRefreshing(true);
|
||||||
@ -71,19 +89,9 @@ export function Flow() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort tasks by status (prioritizing in-progress and new tasks) and date
|
// Sort tasks by date (oldest first)
|
||||||
const sortedTasks = data.tasks.sort((a: Task, b: Task) => {
|
const sortedTasks = data.tasks.sort((a: Task, b: Task) => {
|
||||||
const statusA = getStatusLabel(a.status);
|
return getDateToSort(a) - getDateToSort(b);
|
||||||
const statusB = getStatusLabel(b.status);
|
|
||||||
|
|
||||||
// Prioritize INPROGRESS, then NEW, then DONE
|
|
||||||
const statusPriority: Record<string, number> = {
|
|
||||||
'INPROGRESS': 0,
|
|
||||||
'NEW': 1,
|
|
||||||
'DONE': 2,
|
|
||||||
'UNKNOWN': 3
|
|
||||||
};
|
|
||||||
return (statusPriority[statusA] ?? 3) - (statusPriority[statusB] ?? 3);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Limit to 6 tasks
|
// Limit to 6 tasks
|
||||||
@ -138,9 +146,16 @@ export function Flow() {
|
|||||||
{getStatusLabel(task.status)}
|
{getStatusLabel(task.status)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-gray-500 mt-1 truncate">
|
<div className="flex items-center justify-between mt-1">
|
||||||
{task.projectName}
|
<p className="text-xs text-gray-500 truncate">
|
||||||
</p>
|
{task.projectName}
|
||||||
|
</p>
|
||||||
|
{task.tags && (
|
||||||
|
<p className="text-xs text-blue-500 truncate">
|
||||||
|
{task.tags}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user