Fix in progress today priority
This commit is contained in:
parent
a8548b045b
commit
43481d4df6
2 changed files with 20 additions and 7 deletions
|
|
@ -40,7 +40,11 @@ async function fetchTasksInProgress(visibleTasksWhere) {
|
|||
recurring_parent_id: null,
|
||||
},
|
||||
include: getTaskIncludeConfig(),
|
||||
order: [['priority', 'DESC']],
|
||||
order: [
|
||||
['priority', 'DESC'],
|
||||
['due_date', 'ASC'],
|
||||
['project_id', 'ASC'],
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +71,8 @@ async function fetchTodayPlanTasks(visibleTasksWhere) {
|
|||
include: getTaskIncludeConfig(),
|
||||
order: [
|
||||
['priority', 'DESC'],
|
||||
['created_at', 'ASC'],
|
||||
['due_date', 'ASC'],
|
||||
['project_id', 'ASC'],
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,11 +36,19 @@ export const sortTasksByPriorityDueDateProject = (
|
|||
|
||||
return [...filteredTasks].sort((a, b) => {
|
||||
// 1. Priority (High → Medium → Low → None)
|
||||
const priorityOrder = { high: 3, medium: 2, low: 1 };
|
||||
const aPriority =
|
||||
priorityOrder[a.priority as keyof typeof priorityOrder] || 0;
|
||||
const bPriority =
|
||||
priorityOrder[b.priority as keyof typeof priorityOrder] || 0;
|
||||
// Handle both string ('low', 'medium', 'high') and numeric (0, 1, 2) priority values
|
||||
const getPriorityValue = (priority: any): number => {
|
||||
if (typeof priority === 'number') {
|
||||
// Backend numeric format: 0 = LOW, 1 = MEDIUM, 2 = HIGH
|
||||
return priority;
|
||||
}
|
||||
// Frontend string format
|
||||
const priorityOrder = { high: 2, medium: 1, low: 0 };
|
||||
return priorityOrder[priority as keyof typeof priorityOrder] ?? -1;
|
||||
};
|
||||
|
||||
const aPriority = getPriorityValue(a.priority);
|
||||
const bPriority = getPriorityValue(b.priority);
|
||||
if (aPriority !== bPriority) {
|
||||
return bPriority - aPriority; // Higher priority first
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue