vision refactor
This commit is contained in:
parent
0aaaf468ff
commit
0f12b2a5ab
@ -117,14 +117,31 @@ export function Duties() {
|
||||
}
|
||||
|
||||
// Backend already filters out status=5 (Done) and filters by editorId
|
||||
// Only sort by dateToFinish here
|
||||
const sortedTasks = data
|
||||
// Filter to keep only tasks with due date before today (past due)
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0); // Set to start of today for accurate comparison
|
||||
|
||||
const filteredTasks = data.filter((task: Task) => {
|
||||
const dueDate = getValidDate(task);
|
||||
if (!dueDate) {
|
||||
return false; // Exclude tasks without a due date
|
||||
}
|
||||
|
||||
const taskDueDate = new Date(dueDate);
|
||||
taskDueDate.setHours(0, 0, 0, 0); // Set to start of day for accurate comparison
|
||||
|
||||
// Keep only tasks with due date before today (past due)
|
||||
return taskDueDate < today;
|
||||
});
|
||||
|
||||
// Sort by dateToFinish (oldest first)
|
||||
const sortedTasks = filteredTasks
|
||||
.sort((a: Task, b: Task) => {
|
||||
// First sort by dateToFinish (oldest first)
|
||||
const dateA = getValidDate(a);
|
||||
const dateB = getValidDate(b);
|
||||
|
||||
// If both dates are valid, compare them
|
||||
// Both dates are guaranteed to exist after filtering
|
||||
if (dateA && dateB) {
|
||||
const timeA = new Date(dateA).getTime();
|
||||
const timeB = new Date(dateB).getTime();
|
||||
@ -133,11 +150,7 @@ export function Duties() {
|
||||
}
|
||||
}
|
||||
|
||||
// If only one date is valid, put the task with a date first
|
||||
if (dateA) return -1;
|
||||
if (dateB) return 1;
|
||||
|
||||
// If dates are equal or neither has a date, sort by status (4 before others)
|
||||
// If dates are equal, sort by status (4 before others)
|
||||
if (a.status === 4 && b.status !== 4) return -1;
|
||||
if (b.status === 4 && a.status !== 4) return 1;
|
||||
|
||||
@ -261,7 +274,7 @@ export function Duties() {
|
||||
) : error ? (
|
||||
<div className="text-xs text-red-500 text-center py-3">{error}</div>
|
||||
) : tasks.length === 0 ? (
|
||||
<div className="text-xs text-gray-500 text-center py-6">No tasks with due dates found</div>
|
||||
<div className="text-xs text-gray-500 text-center py-6">Aucune tâche en retard</div>
|
||||
) : (
|
||||
<div className="space-y-2 max-h-[400px] overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent">
|
||||
{tasks.map((task) => (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user