react-weekly-planning 1.0.25 → 1.0.26
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.
- package/index.tsx +11 -18
- package/lib/utils.js +10 -1
- package/lib/utils.ts +18 -9
- package/package.json +1 -1
package/index.tsx
CHANGED
|
@@ -589,24 +589,17 @@ export const getSavedTasks = () => {
|
|
|
589
589
|
}
|
|
590
590
|
const tasksTable: TasksType = JSON.parse(taskSavedString);
|
|
591
591
|
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
taskDate: new Date(taskDate),
|
|
604
|
-
taskExpiryDate: new Date(taskExpiryDate),
|
|
605
|
-
...rest,
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
return validTasks;
|
|
592
|
+
const savedTasks: TasksType | any = tasksTable.map((task) => {
|
|
593
|
+
const { taskDate, taskExpiryDate, ...rest } = task;
|
|
594
|
+
if (taskExpiryDate) {
|
|
595
|
+
return {
|
|
596
|
+
taskDate: new Date(taskDate),
|
|
597
|
+
taskExpiryDate: new Date(taskExpiryDate),
|
|
598
|
+
...rest,
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
return savedTasks;
|
|
610
603
|
};
|
|
611
604
|
|
|
612
605
|
export const deleteTaskSaved = (taskId: string) => {
|
package/lib/utils.js
CHANGED
|
@@ -474,7 +474,16 @@ function saveTasksToLocalStorage(tasks) {
|
|
|
474
474
|
return;
|
|
475
475
|
if (tasksString === "[]")
|
|
476
476
|
return;
|
|
477
|
-
const backup = [
|
|
477
|
+
const backup = [
|
|
478
|
+
...tasks.filter((task) => {
|
|
479
|
+
{
|
|
480
|
+
if (task === null || task === void 0 ? void 0 : task.taskExpiryDate) {
|
|
481
|
+
const taskDate = new Date(task === null || task === void 0 ? void 0 : task.taskExpiryDate);
|
|
482
|
+
return taskDate.getTime() >= Date.now();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}),
|
|
486
|
+
];
|
|
478
487
|
window.localStorage.setItem("CalendarTaskSaved", JSON.stringify(backup));
|
|
479
488
|
}
|
|
480
489
|
}
|
package/lib/utils.ts
CHANGED
|
@@ -600,15 +600,24 @@ const sumHoursByGroups = (
|
|
|
600
600
|
};
|
|
601
601
|
|
|
602
602
|
function saveTasksToLocalStorage(tasks: TasksType) {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
603
|
+
if (typeof window !== "undefined") {
|
|
604
|
+
window.localStorage.setItem("Calendar", "je marche");
|
|
605
|
+
const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
|
|
606
|
+
const tasksString = JSON.stringify(tasks);
|
|
607
|
+
if (tasksSavedString === tasksString) return;
|
|
608
|
+
if (tasksString === "[]") return;
|
|
609
|
+
const backup = [
|
|
610
|
+
...tasks.filter((task) => {
|
|
611
|
+
{
|
|
612
|
+
if (task?.taskExpiryDate) {
|
|
613
|
+
const taskDate = new Date(task?.taskExpiryDate);
|
|
614
|
+
return taskDate.getTime() >= Date.now();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}),
|
|
618
|
+
];
|
|
619
|
+
window.localStorage.setItem("CalendarTaskSaved", JSON.stringify(backup));
|
|
620
|
+
}
|
|
612
621
|
}
|
|
613
622
|
|
|
614
623
|
export {
|