react-weekly-planning 1.0.28 → 1.0.30
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 +3 -1
- package/__tests__/page.test.js +106 -46
- package/__tests__/page.test.tsx +117 -45
- package/babel.config.js +1 -0
- package/components/AddTask/index.js +17 -0
- package/components/AddTask/index.tsx +43 -0
- package/components/CalendarForWeek.js +50 -0
- package/components/CalendarForWeek.tsx +229 -0
- package/components/CalendarForday.js +34 -0
- package/components/CalendarForday.tsx +130 -0
- package/components/DayContainer/index.js +15 -0
- package/components/DayContainer/index.tsx +36 -0
- package/components/GroupContainer/index.js +15 -0
- package/components/GroupContainer/index.tsx +42 -0
- package/components/GroupsHeadContainer/index.js +9 -0
- package/components/GroupsHeadContainer/index.tsx +19 -0
- package/components/SumHoursContainer/index.js +15 -0
- package/components/SumHoursContainer/index.tsx +38 -0
- package/components/SumHoursHead/index.js +9 -0
- package/components/SumHoursHead/index.tsx +22 -0
- package/components/TaskContainer/index.js +35 -0
- package/components/TaskContainer/index.tsx +86 -0
- package/components/TaskList/index.js +5 -0
- package/components/TaskList/index.tsx +20 -0
- package/contexts/CalendarContext.js +12 -12
- package/contexts/CalendarContext.tsx +4 -0
- package/definitions/index.js +1 -1
- package/definitions/index.ts +668 -7
- package/docs/global.html +4982 -4982
- package/docs/index.html +474 -474
- package/docs/index.ts.html +121 -121
- package/docs/scripts/linenumber.js +26 -26
- package/docs/scripts/search.js +38 -38
- package/docs/styles/iframe.css +12 -12
- package/docs/styles/prettify-jsdoc.css +111 -111
- package/docs/styles/prettify-tomorrow.css +132 -132
- package/docs/styles/reset.css +44 -44
- package/hooks/useCalendarDateState.js +19 -0
- package/hooks/useCalendarDateState.ts +44 -0
- package/index.js +70 -248
- package/index.tsx +59 -605
- package/jest.config.js +9 -9
- package/lib/slyles.js +21 -0
- package/lib/slyles.ts +25 -0
- package/lib/utils.js +619 -490
- package/lib/utils.ts +687 -383
- package/out/index.html +128 -128
- package/out/scripts/linenumber.js +26 -26
- package/out/scripts/search.js +38 -38
- package/out/styles/iframe.css +12 -12
- package/out/styles/prettify-jsdoc.css +111 -111
- package/out/styles/prettify-tomorrow.css +132 -132
- package/out/styles/reset.css +44 -44
- package/package.json +81 -71
- package/style.css +26 -4
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ It is possible to use either Weekoffset or Date, or even both simultaneously.
|
|
|
85
85
|
|
|
86
86
|
**Example**:
|
|
87
87
|
```jsx
|
|
88
|
-
import {getSavedTasks} from "react-weekly-planning";
|
|
88
|
+
import {getSavedTasks} from "react-weekly-planning/lib/utils";
|
|
89
89
|
const [tasks,setTasks]=useState([])
|
|
90
90
|
|
|
91
91
|
useEffect(()=>{
|
|
@@ -173,6 +173,7 @@ Props for the Calendar component.
|
|
|
173
173
|
|
|
174
174
|
**Example**:
|
|
175
175
|
```javascript
|
|
176
|
+
import {updateOffsetWithDateCalendar} from "react-weekly-planning/lib/utils";
|
|
176
177
|
const offset = updateOffsetWithDateCalendar(new Date());
|
|
177
178
|
console.log(offset); // Logs the week offset for the given date
|
|
178
179
|
```
|
|
@@ -186,6 +187,7 @@ Props for the Calendar component.
|
|
|
186
187
|
|
|
187
188
|
**Example**:
|
|
188
189
|
```javascript
|
|
190
|
+
import {millisecondsToHours} from "react-weekly-planning/lib/utils";
|
|
189
191
|
const formattedTime = millisecondsToHours(1716905215397);
|
|
190
192
|
console.log(formattedTime); // Logs the formatted time for 14h06
|
|
191
193
|
```
|
package/__tests__/page.test.js
CHANGED
|
@@ -1,46 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import "@testing-library/jest-dom";
|
|
11
|
+
import ical from "ical";
|
|
12
|
+
export function parseICSToTasks(icsData, group) {
|
|
13
|
+
var _a;
|
|
14
|
+
const events = ical.parseICS(icsData);
|
|
15
|
+
const tasks = [];
|
|
16
|
+
for (const key in events) {
|
|
17
|
+
const event = events[key];
|
|
18
|
+
if (event.type === "VEVENT") {
|
|
19
|
+
const taskStart = event.start
|
|
20
|
+
? new Date(event.start).getTime()
|
|
21
|
+
: new Date().getTime();
|
|
22
|
+
const taskEnd = event.end
|
|
23
|
+
? new Date(event.end).getTime()
|
|
24
|
+
: new Date().getTime();
|
|
25
|
+
const taskDate = event.start ? new Date(event.start) : new Date();
|
|
26
|
+
const taskSummary = event.summary || "";
|
|
27
|
+
const taskLocation = event.location || "";
|
|
28
|
+
const taskTimezone = "";
|
|
29
|
+
const taskCreatedAt = event.created
|
|
30
|
+
? new Date(event.created)
|
|
31
|
+
: new Date();
|
|
32
|
+
const taskExpiryDate = ((_a = event.rrule) === null || _a === void 0 ? void 0 : _a.options.until)
|
|
33
|
+
? new Date(event.rrule.options.until)
|
|
34
|
+
: new Date();
|
|
35
|
+
const task = {
|
|
36
|
+
taskStart,
|
|
37
|
+
taskEnd,
|
|
38
|
+
taskDate,
|
|
39
|
+
taskSummary,
|
|
40
|
+
taskLocation,
|
|
41
|
+
taskTimzone: taskTimezone,
|
|
42
|
+
groupId: group,
|
|
43
|
+
dayIndex: taskDate.getDay() || 0,
|
|
44
|
+
taskId: event.uid || "",
|
|
45
|
+
taskCreatedAt,
|
|
46
|
+
taskExpiryDate,
|
|
47
|
+
};
|
|
48
|
+
tasks.push(task);
|
|
49
|
+
if (!event.start)
|
|
50
|
+
return [];
|
|
51
|
+
// Gestion des occurrences récurrentes
|
|
52
|
+
if (event.rrule) {
|
|
53
|
+
const occurrences = event.rrule.between(event.start, taskExpiryDate || new Date());
|
|
54
|
+
occurrences.forEach((occurrence) => {
|
|
55
|
+
tasks.push(Object.assign(Object.assign({}, task), { taskStart: occurrence.getTime(), taskEnd: occurrence.getTime() + (taskEnd - taskStart), taskDate: new Date(occurrence.getTime()), dayIndex: new Date(occurrence.getTime()).getDay() }));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return tasks;
|
|
61
|
+
}
|
|
62
|
+
import axios from "axios";
|
|
63
|
+
// Get ICS text however you like, example below
|
|
64
|
+
// Make sure you have the right CORS settings if needed
|
|
65
|
+
const convert = (fileLocation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
const task = fileLocation.map((link) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
const icsRes = yield axios.get(link);
|
|
69
|
+
const icstext = yield icsRes.data;
|
|
70
|
+
const data = parseICSToTasks(icstext, "morel");
|
|
71
|
+
return data;
|
|
72
|
+
}));
|
|
73
|
+
console.log(task);
|
|
74
|
+
return "success";
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return "error";
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
export function convertTasksToIcsFormat(tasks) {
|
|
81
|
+
const ics = tasks.reduce((previousIcs, task) => {
|
|
82
|
+
previousIcs += `
|
|
83
|
+
|
|
84
|
+
BEGIN:VCALENDAR
|
|
85
|
+
VERSION:1.0
|
|
86
|
+
BEGIN:VEVENT
|
|
87
|
+
DTSTART:${task.taskStart}
|
|
88
|
+
DTEND:${task.taskEnd}
|
|
89
|
+
LOCATION:
|
|
90
|
+
DESCRIPTION:Purpose: Provide example of this file type Document file type: ICS Version: 1.0 Created by http://www.online-convert.com More example files: http://www.online-convert.com/file-type License: http://creativecommons.org/licenses Feel free to use & share the file according to the license above.
|
|
91
|
+
SUMMARY:ICS test file
|
|
92
|
+
PRIORITY:3
|
|
93
|
+
END:VEVENT
|
|
94
|
+
END:VCALENDAR
|
|
95
|
+
|
|
96
|
+
`;
|
|
97
|
+
return previousIcs;
|
|
98
|
+
}, "");
|
|
99
|
+
return ics;
|
|
100
|
+
}
|
|
101
|
+
test("the fetch fails with an error", () => {
|
|
102
|
+
return convert([
|
|
103
|
+
"https://firebasestorage.googleapis.com/v0/b/ashtonv2.appspot.com/o/example.ics?alt=media&token=679cab97-cde2-4074-b96f-b63c10f1b7e2",
|
|
104
|
+
"https://firebasestorage.googleapis.com/v0/b/ashtonv2.appspot.com/o/example.ics?alt=media&token=679cab97-cde2-4074-b96f-b63c10f1b7e2",
|
|
105
|
+
]).catch((error) => expect(error).toMatch("error"));
|
|
106
|
+
});
|
package/__tests__/page.test.tsx
CHANGED
|
@@ -1,57 +1,129 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import Calendar from "..";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { TaskFeildsType } from "../definitions";
|
|
5
|
+
import { icsToJson } from "ics-to-json";
|
|
6
|
+
|
|
7
|
+
import ical from "ical";
|
|
8
|
+
|
|
9
|
+
export function parseICSToTasks(
|
|
10
|
+
icsData: string,
|
|
11
|
+
group: string
|
|
12
|
+
): TaskFeildsType[] {
|
|
13
|
+
const events = ical.parseICS(icsData);
|
|
14
|
+
const tasks: TaskFeildsType[] = [];
|
|
15
|
+
|
|
16
|
+
for (const key in events) {
|
|
17
|
+
const event = events[key];
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
if (event.type === "VEVENT") {
|
|
20
|
+
const taskStart = event.start
|
|
21
|
+
? new Date(event.start).getTime()
|
|
22
|
+
: new Date().getTime();
|
|
23
|
+
const taskEnd = event.end
|
|
24
|
+
? new Date(event.end).getTime()
|
|
25
|
+
: new Date().getTime();
|
|
26
|
+
const taskDate = event.start ? new Date(event.start) : new Date();
|
|
27
|
+
const taskSummary = event.summary || "";
|
|
28
|
+
const taskLocation = event.location || "";
|
|
29
|
+
const taskTimezone = "";
|
|
30
|
+
const taskCreatedAt = event.created
|
|
31
|
+
? new Date(event.created)
|
|
32
|
+
: new Date();
|
|
33
|
+
const taskExpiryDate = event.rrule?.options.until
|
|
34
|
+
? new Date(event.rrule.options.until)
|
|
35
|
+
: new Date();
|
|
14
36
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
const task: TaskFeildsType[][number] = {
|
|
38
|
+
taskStart,
|
|
39
|
+
taskEnd,
|
|
40
|
+
taskDate,
|
|
41
|
+
taskSummary,
|
|
42
|
+
taskLocation,
|
|
43
|
+
taskTimzone: taskTimezone,
|
|
44
|
+
groupId: group,
|
|
45
|
+
dayIndex: taskDate.getDay() || 0,
|
|
46
|
+
taskId: event.uid || "",
|
|
47
|
+
taskCreatedAt,
|
|
48
|
+
taskExpiryDate,
|
|
49
|
+
};
|
|
18
50
|
|
|
19
|
-
|
|
51
|
+
tasks.push(task);
|
|
20
52
|
|
|
21
|
-
|
|
22
|
-
const numeroSemaineSelectionnee = getWeekNumber(dateSelectionnee);
|
|
53
|
+
if (!event.start) return [];
|
|
23
54
|
|
|
24
|
-
|
|
55
|
+
// Gestion des occurrences récurrentes
|
|
56
|
+
if (event.rrule) {
|
|
57
|
+
const occurrences = event.rrule.between(
|
|
58
|
+
event.start,
|
|
59
|
+
taskExpiryDate || new Date()
|
|
60
|
+
);
|
|
25
61
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
62
|
+
occurrences.forEach((occurrence) => {
|
|
63
|
+
tasks.push({
|
|
64
|
+
...task,
|
|
65
|
+
taskStart: occurrence.getTime(),
|
|
66
|
+
taskEnd: occurrence.getTime() + (taskEnd - taskStart),
|
|
67
|
+
taskDate: new Date(occurrence.getTime()),
|
|
68
|
+
dayIndex: new Date(occurrence.getTime()).getDay(),
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
30
74
|
|
|
31
|
-
return
|
|
75
|
+
return tasks;
|
|
32
76
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
77
|
+
|
|
78
|
+
import axios from "axios";
|
|
79
|
+
// Get ICS text however you like, example below
|
|
80
|
+
// Make sure you have the right CORS settings if needed
|
|
81
|
+
const convert = async (fileLocation: string[]) => {
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const task = fileLocation.map(async (link) => {
|
|
85
|
+
const icsRes = await axios.get(link);
|
|
86
|
+
const icstext:string = await icsRes.data;
|
|
87
|
+
const data = parseICSToTasks(icstext, "morel");
|
|
88
|
+
return data;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
console.log(task);
|
|
92
|
+
return "success";
|
|
93
|
+
} catch (error) {
|
|
94
|
+
return "error";
|
|
43
95
|
}
|
|
44
|
-
|
|
96
|
+
};
|
|
45
97
|
|
|
46
|
-
|
|
98
|
+
|
|
99
|
+
export function convertTasksToIcsFormat(tasks: TaskFeildsType[]) {
|
|
100
|
+
const ics = tasks.reduce((previousIcs: string, task: TaskFeildsType) => {
|
|
101
|
+
previousIcs += `
|
|
102
|
+
|
|
103
|
+
BEGIN:VCALENDAR
|
|
104
|
+
VERSION:1.0
|
|
105
|
+
BEGIN:VEVENT
|
|
106
|
+
DTSTART:${task.taskStart}
|
|
107
|
+
DTEND:${task.taskEnd}
|
|
108
|
+
LOCATION:
|
|
109
|
+
DESCRIPTION:Purpose: Provide example of this file type Document file type: ICS Version: 1.0 Created by http://www.online-convert.com More example files: http://www.online-convert.com/file-type License: http://creativecommons.org/licenses Feel free to use & share the file according to the license above.
|
|
110
|
+
SUMMARY:ICS test file
|
|
111
|
+
PRIORITY:3
|
|
112
|
+
END:VEVENT
|
|
113
|
+
END:VCALENDAR
|
|
114
|
+
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
return previousIcs;
|
|
118
|
+
}, "");
|
|
119
|
+
|
|
120
|
+
return ics;
|
|
47
121
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
expect(makeCalcul(nextWeek)).toBe(-14);
|
|
56
|
-
});
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
test("the fetch fails with an error", () => {
|
|
125
|
+
return convert([
|
|
126
|
+
"https://firebasestorage.googleapis.com/v0/b/ashtonv2.appspot.com/o/example.ics?alt=media&token=679cab97-cde2-4074-b96f-b63c10f1b7e2",
|
|
127
|
+
"https://firebasestorage.googleapis.com/v0/b/ashtonv2.appspot.com/o/example.ics?alt=media&token=679cab97-cde2-4074-b96f-b63c10f1b7e2",
|
|
128
|
+
]).catch((error) => expect(error).toMatch("error"));
|
|
57
129
|
});
|
package/babel.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {presets: ['@babel/preset-env']}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
const AddTask = ({ currentGroup, handleAddTask, addTaskRender, dayInfo, addTaskStyle, addTaskClassName, }) => {
|
|
4
|
+
if (addTaskRender) {
|
|
5
|
+
return (_jsx(_Fragment, { children: addTaskRender({
|
|
6
|
+
currentGroup,
|
|
7
|
+
dayInfo,
|
|
8
|
+
}) }));
|
|
9
|
+
}
|
|
10
|
+
const handleClick = () => {
|
|
11
|
+
if (!handleAddTask)
|
|
12
|
+
return;
|
|
13
|
+
handleAddTask(currentGroup, dayInfo);
|
|
14
|
+
};
|
|
15
|
+
return (_jsx("div", { onClick: handleClick, style: addTaskStyle, className: `addPlanStyle ${addTaskClassName}`, children: "+" }));
|
|
16
|
+
};
|
|
17
|
+
export default memo(AddTask);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { AddTaskPropsType } from "../../definitions";
|
|
3
|
+
|
|
4
|
+
const AddTask = ({
|
|
5
|
+
|
|
6
|
+
currentGroup,
|
|
7
|
+
handleAddTask,
|
|
8
|
+
addTaskRender,
|
|
9
|
+
dayInfo,
|
|
10
|
+
addTaskStyle,
|
|
11
|
+
addTaskClassName,
|
|
12
|
+
|
|
13
|
+
}: AddTaskPropsType) => {
|
|
14
|
+
if (addTaskRender) {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
{addTaskRender({
|
|
18
|
+
currentGroup,
|
|
19
|
+
dayInfo,
|
|
20
|
+
})}
|
|
21
|
+
</>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const handleClick = () => {
|
|
26
|
+
|
|
27
|
+
if (!handleAddTask) return;
|
|
28
|
+
handleAddTask(currentGroup, dayInfo);
|
|
29
|
+
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
onClick={handleClick}
|
|
35
|
+
style={addTaskStyle}
|
|
36
|
+
className={`addPlanStyle ${addTaskClassName}`}
|
|
37
|
+
>
|
|
38
|
+
+
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default memo(AddTask);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import GroupContainer from "./GroupContainer";
|
|
4
|
+
import GroupsHeadContainer from "./GroupsHeadContainer";
|
|
5
|
+
import { groupTdStyle, theadTrStyle } from "../lib/slyles";
|
|
6
|
+
import DayContainer from "./DayContainer";
|
|
7
|
+
import SumHoursHead from "./SumHoursHead";
|
|
8
|
+
import { compareWeekOffset, getSessionStorageRecordForDragAndDrop, saveTasksToLocalStorage, sumHoursByGroups, } from "../lib/utils";
|
|
9
|
+
import TaskContainer from "./TaskContainer";
|
|
10
|
+
import AddTask from "./AddTask";
|
|
11
|
+
import SumHoursContainer from "./SumHoursContainer";
|
|
12
|
+
import { memo, useEffect } from "react";
|
|
13
|
+
import useCalendarDateState from "../hooks/useCalendarDateState";
|
|
14
|
+
function CalendarForWeek(props) {
|
|
15
|
+
var _a;
|
|
16
|
+
const { dailyHours, weekDays } = useCalendarDateState(props.date, props.weekOffset, props.timeZone);
|
|
17
|
+
const handleDragOver = (event) => {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
};
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
saveTasksToLocalStorage(props.tasks);
|
|
22
|
+
}, [props.tasks]);
|
|
23
|
+
return (_jsxs("table", { className: `planningCalendar ${props.className}`, style: Object.assign({}, props.style), children: [_jsx("thead", { children: _jsxs("tr", { className: `${props.rowsClassName}`, style: Object.assign(Object.assign({}, theadTrStyle), props.rowsStyle), children: [_jsx("th", { className: `dayTh ${props.groupsColsClassName}`, style: Object.assign({}, props.groupsColsStyle), children: _jsx(GroupsHeadContainer, { className: `${props.groupHeadContainerClassName}`, style: props.groupHeadContainerStyle, groupsHeadRender: props.groupsHeadRender }) }), weekDays.map((day, i) => (_jsx("th", { className: `${props.daysColsClassName}`, style: Object.assign({}, props.daysColsStyle), children: _jsx(DayContainer, { style: props.dayStyle, className: props.dayClassName, dayIndex: i, dayRender: props.dayRender, day: day.day, dayOfTheMonth: day.dayOfTheMonth, dayMonth: day.dayMonth, dayYear: day.dayYear }) }, i))), _jsx("th", { className: `totalTh ${props.hoursColsClassName}`, style: props.hoursColsStyle, children: _jsx(SumHoursHead, { className: props.sumHoursHeadClassName, style: props.sumHoursHeadStyle, sumHoursHeadRender: props.sumHoursHeadRender }) })] }, "") }), _jsx("tbody", { children: (_a = props.groups) === null || _a === void 0 ? void 0 : _a.map((group, i) => (_jsxs("tr", { className: `${props.rowsClassName}`, style: Object.assign({}, props.rowsStyle), children: [_jsx("td", { className: `${props.groupsColsClassName}`, style: Object.assign(Object.assign({}, groupTdStyle), props.groupsColsStyle), children: _jsx(GroupContainer, { style: props.groupContainerStyle, className: props.groupContainerClassName, groupRender: props.groupRender, currentGroup: group, handleClickGroup: props.handleClickGroup }) }, i), dailyHours.map((_, positionDay) => (_jsx("td", { onDragOver: handleDragOver, onDrop: (event) => {
|
|
24
|
+
if (!props.handleDropTask || !props.tasks)
|
|
25
|
+
return;
|
|
26
|
+
const dropInfo = getSessionStorageRecordForDragAndDrop(props.tasks, positionDay, group.id);
|
|
27
|
+
if (!dropInfo)
|
|
28
|
+
return;
|
|
29
|
+
props.handleDropTask(event, dropInfo.taskDropStart, dropInfo.taskDropEnd, dropInfo.taskDropDate, group.id, positionDay, dropInfo.newTask, dropInfo.newTasks);
|
|
30
|
+
}, id: `td-${group.id}day-i`, className: props.dayColsClassName, style: props.dayColsStyle, children: _jsxs("div", { style: {
|
|
31
|
+
display: "flex",
|
|
32
|
+
width: "100%",
|
|
33
|
+
height: "100%",
|
|
34
|
+
flexDirection: "column",
|
|
35
|
+
padding: "5px",
|
|
36
|
+
}, children: [_jsx(_Fragment, { children: props.tasks
|
|
37
|
+
.map((task, taskKey) => {
|
|
38
|
+
if (task.dayIndex === positionDay &&
|
|
39
|
+
task.groupId === group.id &&
|
|
40
|
+
compareWeekOffset(props.date, props.weekOffset || 0, task.taskDate)) {
|
|
41
|
+
return (_jsx(TaskContainer, { handleDragTask: props.handleDragTask, taskRender: props.taskRender, handleDragTaskEnd: props.handleDragTaskEnd, style: props.taskContainerStyle, className: `${props.taskContainerClassName}`, currentTask: task, handleClickTask: props.handleClickTask }, `${taskKey} task`));
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
return "";
|
|
45
|
+
}) }), _jsx(AddTask, { addTaskStyle: props.addTaskStyle, addTaskClassName: props.addTaskClassName, currentGroup: group, dayInfo: dailyHours[positionDay], addTaskRender: props.addTaskRender, handleAddTask: props.handleAddTask })] }, positionDay) }, `td-${group.id}day-i${positionDay}`))), _jsx("td", { style: props.hoursColsStyle, className: props.hoursColsClassName, children: _jsx(SumHoursContainer, { groupId: group.id, tasks: props.tasks, weekOffset: props.weekOffset || 0, calendarDate: props.date, sumHoursRender: props.sumHoursRender, sumHoursByGroups: sumHoursByGroups(group.id, props.tasks, props.weekOffset || 0, props.date), className: props.sumHoursContainerClassName, style: props.sumHoursContainerStyle }) }, `${i}sumHours`)] }, `${i} tr`))) })] }));
|
|
46
|
+
}
|
|
47
|
+
export default memo(CalendarForWeek, (prevProps, nextProps) => prevProps.tasks === nextProps.tasks &&
|
|
48
|
+
prevProps.date === nextProps.date &&
|
|
49
|
+
prevProps.groups === nextProps.groups &&
|
|
50
|
+
prevProps.weekOffset === nextProps.weekOffset);
|