@kkkarsss/ui 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export const calculateTaskPositions = (tasks) => {
|
|
2
|
-
const tasksToRender = [...tasks]
|
|
2
|
+
const tasksToRender = [...tasks]
|
|
3
|
+
.map((t) => ({
|
|
4
|
+
...t,
|
|
5
|
+
dueDate: t.dueDate instanceof Date ? t.dueDate : new Date(t.dueDate),
|
|
6
|
+
}))
|
|
7
|
+
.filter((t) => t.dueDate && !isNaN(t.dueDate.getTime()))
|
|
8
|
+
.sort((a, b) => a.dueDate.getTime() - b.dueDate.getTime());
|
|
3
9
|
const columns = [];
|
|
4
10
|
tasksToRender.forEach((task) => {
|
|
5
11
|
const startTime = task.dueDate.getTime();
|
|
@@ -62,17 +68,10 @@ export const calculateTaskPositions = (tasks) => {
|
|
|
62
68
|
export const groupTasksByHour = (tasksWithPosition) => {
|
|
63
69
|
const map = {};
|
|
64
70
|
tasksWithPosition.forEach((task) => {
|
|
65
|
-
|
|
66
|
-
if (!(date instanceof Date)) {
|
|
67
|
-
date = new Date(date);
|
|
68
|
-
}
|
|
69
|
-
if (isNaN(date.getTime())) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const hour = date.getHours();
|
|
71
|
+
const hour = task.dueDate.getHours();
|
|
73
72
|
if (!map[hour])
|
|
74
73
|
map[hour] = [];
|
|
75
|
-
map[hour].push(
|
|
74
|
+
map[hour].push(task);
|
|
76
75
|
});
|
|
77
76
|
return map;
|
|
78
77
|
};
|