react-weekly-planning 1.0.23 → 1.0.25

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/README.md CHANGED
@@ -11,7 +11,9 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
11
11
 
12
12
  ![Planning Screenshot](https://raw.githubusercontent.com/Yvesmorel/react-pweekly-planning/main/assets/planning-screenshot.webp)
13
13
 
14
+ [See the demo](https://react-weekly-planning-demo.vercel.app)
14
15
 
16
+ [Demo repository](https://github.com/Yvesmorel/react-weekly-planning-demo.git)
15
17
 
16
18
  #### `weekOffset`
17
19
 
@@ -68,6 +70,30 @@ It is possible to use either Weekoffset or Date, or even both simultaneously.
68
70
  <Calendar tasks={tasks} ... />
69
71
  ```
70
72
 
73
+ - **Supplementary property** : If you want the tasks to be saved up to a date of your choice you can define the `taskExpiryDate` property. It's an idea of [Patrick Aimé](https://www.linkedin.com/in/patrick-aime?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=android_app).
74
+
75
+ - **Example**:Here's how to create a task that will expire in a day.
76
+ ```jsx
77
+ const tasks = [
78
+ { taskId: '1', taskStart:'Time in milliseconde', taskEnd:'Time in milliseconde', task: 'Task 1', taskDate: new Date(), groupId: '1', dayIndex: 0,taskExpiryDate:new Date(Date.now() + 86400000) ... }
79
+ ];
80
+
81
+ <Calendar tasks={tasks} ... />
82
+ ```
83
+
84
+ `taskExpiryDate` is used with `getSavedTasks()` To obtain the saved tasks.
85
+
86
+ **Example**:
87
+ ```jsx
88
+ import {getSavedTasks} from "react-weekly-planning";
89
+ const [tasks,setTasks]=useState([])
90
+
91
+ useEffect(()=>{
92
+ setTasks(getSavedTasks())
93
+ },[])
94
+
95
+ <Calendar tasks={tasks} ... />
96
+ ```
71
97
  ---
72
98
  ---
73
99
 
package/index.js CHANGED
@@ -217,7 +217,7 @@ export const checkDuplicates = (tasks, taskStart, taskEnd, groupId) => {
217
217
  taskStart <= task.taskEnd)).filter((task) => task.groupId === groupId);
218
218
  return findDuplicates.length > 0;
219
219
  };
220
- export const getTasksSaved = () => {
220
+ export const getSavedTasks = () => {
221
221
  const taskSavedString = window.localStorage.getItem("CalendarTaskSaved");
222
222
  if (!taskSavedString) {
223
223
  return [];
package/index.tsx CHANGED
@@ -582,13 +582,14 @@ export const checkDuplicates = (
582
582
  return findDuplicates.length > 0;
583
583
  };
584
584
 
585
- export const getTasksSaved = () => {
585
+ export const getSavedTasks = () => {
586
586
  const taskSavedString = window.localStorage.getItem("CalendarTaskSaved");
587
587
  if (!taskSavedString) {
588
588
  return [];
589
589
  }
590
590
  const tasksTable: TasksType = JSON.parse(taskSavedString);
591
- const validTasks = tasksTable
591
+
592
+ const validTasks:TasksType | any = tasksTable
592
593
  .filter((task) => {
593
594
  if (task?.taskExpiryDate) {
594
595
  const taskDate = new Date(task?.taskExpiryDate);
package/lib/utils.js CHANGED
@@ -466,15 +466,16 @@ const sumHoursByGroups = (groupId, tasks, weekOffset, calendarDate) => {
466
466
  return sum;
467
467
  };
468
468
  function saveTasksToLocalStorage(tasks) {
469
- if (!window)
470
- return;
471
- const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
472
- const tasksString = JSON.stringify(tasks);
473
- if (tasksSavedString === tasksString)
474
- return;
475
- if (tasksString === "[]")
476
- return;
477
- const backup = [...tasks.filter((task) => task.taskExpiryDate)];
478
- window.localStorage.setItem("CalendarTaskSaved", JSON.stringify(backup));
469
+ if (typeof window !== "undefined") {
470
+ window.localStorage.setItem("Calendar", "je marche");
471
+ const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
472
+ const tasksString = JSON.stringify(tasks);
473
+ if (tasksSavedString === tasksString)
474
+ return;
475
+ if (tasksString === "[]")
476
+ return;
477
+ const backup = [...tasks.filter((task) => task.taskExpiryDate)];
478
+ window.localStorage.setItem("CalendarTaskSaved", JSON.stringify(backup));
479
+ }
479
480
  }
480
481
  export { getWeeksListUpdate, saveTasksToLocalStorage, clickedDate, getCalandarDays, startDateMilliseconds, endDateMilliseconds, getDayHourly, millisecondsToDate, getWeekDays, formatDateToCustomFormat, displayDayOnModalLeft, millisecondsToInt, getWeekMonthAndYear, getWeeksList, getDoubleWeeksList, calculerEcartSemaine, calculateTimeOfDayRange, getSessionStorageRecordForDragAndDrop, compareWeekOffset, sumHoursByGroups, };
package/lib/utils.ts CHANGED
@@ -600,13 +600,15 @@ const sumHoursByGroups = (
600
600
  };
601
601
 
602
602
  function saveTasksToLocalStorage(tasks: TasksType) {
603
- if (!window) return;
603
+ if (typeof window !== "undefined") {
604
+ window.localStorage.setItem("Calendar","je marche");
604
605
  const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
605
606
  const tasksString = JSON.stringify(tasks);
606
607
  if (tasksSavedString === tasksString) return;
607
608
  if (tasksString === "[]") return;
608
609
  const backup = [...tasks.filter((task) => task.taskExpiryDate)];
609
610
  window.localStorage.setItem("CalendarTaskSaved", JSON.stringify(backup));
611
+ }
610
612
  }
611
613
 
612
614
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-weekly-planning",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest",