react-weekly-planning 1.0.25 → 1.0.27
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.js +2 -9
- package/index.tsx +11 -18
- package/lib/utils.js +13 -4
- package/lib/utils.ts +21 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -223,20 +223,13 @@ export const getSavedTasks = () => {
|
|
|
223
223
|
return [];
|
|
224
224
|
}
|
|
225
225
|
const tasksTable = JSON.parse(taskSavedString);
|
|
226
|
-
const
|
|
227
|
-
.filter((task) => {
|
|
228
|
-
if (task === null || task === void 0 ? void 0 : task.taskExpiryDate) {
|
|
229
|
-
const taskDate = new Date(task === null || task === void 0 ? void 0 : task.taskExpiryDate);
|
|
230
|
-
return taskDate.getTime() >= Date.now();
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
.map((task) => {
|
|
226
|
+
const savedTasks = tasksTable.map((task) => {
|
|
234
227
|
const { taskDate, taskExpiryDate } = task, rest = __rest(task, ["taskDate", "taskExpiryDate"]);
|
|
235
228
|
if (taskExpiryDate) {
|
|
236
229
|
return Object.assign({ taskDate: new Date(taskDate), taskExpiryDate: new Date(taskExpiryDate) }, rest);
|
|
237
230
|
}
|
|
238
231
|
});
|
|
239
|
-
return
|
|
232
|
+
return savedTasks;
|
|
240
233
|
};
|
|
241
234
|
export const deleteTaskSaved = (taskId) => {
|
|
242
235
|
const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
|
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
|
@@ -448,9 +448,9 @@ function getSessionStorageRecordForDragAndDrop(tasks, positionDay, dropGroupId)
|
|
|
448
448
|
return { taskDropStart, taskDropEnd, taskDropDate, newTask, newTasks };
|
|
449
449
|
}
|
|
450
450
|
function compareWeekOffset(calendarDate, weekOffset, taskDate) {
|
|
451
|
-
if (taskDate.getDay() === 0 && calculerEcartSemaine(taskDate) === -7) {
|
|
452
|
-
|
|
453
|
-
}
|
|
451
|
+
// if (taskDate.getDay() === 0 && calculerEcartSemaine(taskDate) === -7) {
|
|
452
|
+
// return true;
|
|
453
|
+
// }
|
|
454
454
|
if (calendarDate)
|
|
455
455
|
return (calculerEcartSemaine(calendarDate) === calculerEcartSemaine(taskDate));
|
|
456
456
|
return weekOffset === calculerEcartSemaine(taskDate);
|
|
@@ -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
|
@@ -571,9 +571,9 @@ function compareWeekOffset(
|
|
|
571
571
|
weekOffset: number,
|
|
572
572
|
taskDate: Date
|
|
573
573
|
) {
|
|
574
|
-
if (taskDate.getDay() === 0 && calculerEcartSemaine(taskDate) === -7) {
|
|
575
|
-
|
|
576
|
-
}
|
|
574
|
+
// if (taskDate.getDay() === 0 && calculerEcartSemaine(taskDate) === -7) {
|
|
575
|
+
// return true;
|
|
576
|
+
// }
|
|
577
577
|
if (calendarDate)
|
|
578
578
|
return (
|
|
579
579
|
calculerEcartSemaine(calendarDate) === calculerEcartSemaine(taskDate)
|
|
@@ -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 {
|