react-weekly-planning 1.0.24 → 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
@@ -468,7 +468,6 @@ const sumHoursByGroups = (groupId, tasks, weekOffset, calendarDate) => {
468
468
  function saveTasksToLocalStorage(tasks) {
469
469
  if (typeof window !== "undefined") {
470
470
  window.localStorage.setItem("Calendar", "je marche");
471
- console.log(tasks);
472
471
  const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
473
472
  const tasksString = JSON.stringify(tasks);
474
473
  if (tasksSavedString === tasksString)
package/lib/utils.ts CHANGED
@@ -602,7 +602,6 @@ const sumHoursByGroups = (
602
602
  function saveTasksToLocalStorage(tasks: TasksType) {
603
603
  if (typeof window !== "undefined") {
604
604
  window.localStorage.setItem("Calendar","je marche");
605
- console.log(tasks);
606
605
  const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
607
606
  const tasksString = JSON.stringify(tasks);
608
607
  if (tasksSavedString === tasksString) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-weekly-planning",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest",