react-weekly-planning 1.0.29 → 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/__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 -17
- package/components/AddTask/index.tsx +4 -0
- package/components/CalendarForWeek.js +50 -0
- package/components/{CalendarTable.tsx → CalendarForWeek.tsx} +49 -39
- package/components/CalendarForday.js +34 -0
- package/components/CalendarForday.tsx +130 -0
- package/components/DayContainer/index.js +15 -15
- package/components/DayContainer/index.tsx +1 -0
- package/components/GroupContainer/index.js +15 -15
- package/components/GroupContainer/index.tsx +1 -0
- package/components/GroupsHeadContainer/index.js +9 -9
- package/components/SumHoursContainer/index.js +15 -15
- package/components/SumHoursHead/index.js +9 -9
- package/components/TaskContainer/index.js +35 -35
- package/components/TaskContainer/index.tsx +1 -1
- 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 +644 -4
- 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 -13
- package/hooks/useCalendarDateState.ts +28 -8
- package/index.js +70 -52
- package/index.tsx +57 -41
- package/jest.config.js +9 -9
- package/lib/slyles.js +21 -21
- package/lib/slyles.ts +1 -1
- package/lib/utils.js +619 -317
- package/lib/utils.ts +558 -6
- 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/components/CalendarTable.js +0 -48
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']}
|
|
@@ -1,17 +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);
|
|
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);
|
|
@@ -2,12 +2,14 @@ import { memo } from "react";
|
|
|
2
2
|
import { AddTaskPropsType } from "../../definitions";
|
|
3
3
|
|
|
4
4
|
const AddTask = ({
|
|
5
|
+
|
|
5
6
|
currentGroup,
|
|
6
7
|
handleAddTask,
|
|
7
8
|
addTaskRender,
|
|
8
9
|
dayInfo,
|
|
9
10
|
addTaskStyle,
|
|
10
11
|
addTaskClassName,
|
|
12
|
+
|
|
11
13
|
}: AddTaskPropsType) => {
|
|
12
14
|
if (addTaskRender) {
|
|
13
15
|
return (
|
|
@@ -21,8 +23,10 @@ const AddTask = ({
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const handleClick = () => {
|
|
26
|
+
|
|
24
27
|
if (!handleAddTask) return;
|
|
25
28
|
handleAddTask(currentGroup, dayInfo);
|
|
29
|
+
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
return (
|
|
@@ -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);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
CalendarPropsType,
|
|
4
|
+
CalendarTablePropsType,
|
|
5
|
+
TaskFeildsType,
|
|
6
|
+
} from "../definitions";
|
|
4
7
|
import GroupContainer from "./GroupContainer";
|
|
5
8
|
import GroupsHeadContainer from "./GroupsHeadContainer";
|
|
6
9
|
|
|
@@ -13,27 +16,26 @@ import {
|
|
|
13
16
|
getSessionStorageRecordForDragAndDrop,
|
|
14
17
|
saveTasksToLocalStorage,
|
|
15
18
|
sumHoursByGroups,
|
|
19
|
+
updateOffsetWithDateCalendar,
|
|
16
20
|
} from "../lib/utils";
|
|
17
21
|
|
|
18
22
|
import TaskContainer from "./TaskContainer";
|
|
23
|
+
|
|
19
24
|
import AddTask from "./AddTask";
|
|
20
25
|
import SumHoursContainer from "./SumHoursContainer";
|
|
21
|
-
import { memo,
|
|
26
|
+
import { memo, useEffect } from "react";
|
|
22
27
|
import useCalendarDateState from "../hooks/useCalendarDateState";
|
|
23
28
|
|
|
24
|
-
function
|
|
25
|
-
|
|
29
|
+
function CalendarForWeek(props: CalendarTablePropsType) {
|
|
26
30
|
const { dailyHours, weekDays } = useCalendarDateState(
|
|
27
31
|
props.date,
|
|
28
|
-
props.weekOffset
|
|
32
|
+
props.weekOffset,
|
|
33
|
+
props.timeZone
|
|
29
34
|
);
|
|
30
35
|
|
|
31
|
-
const handleDragOver =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
[]
|
|
36
|
-
);
|
|
36
|
+
const handleDragOver = (event: React.DragEvent<HTMLTableCellElement>) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
};
|
|
37
39
|
|
|
38
40
|
useEffect(() => {
|
|
39
41
|
saveTasksToLocalStorage(props.tasks);
|
|
@@ -50,7 +52,10 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
50
52
|
style={{ ...theadTrStyle, ...props.rowsStyle }}
|
|
51
53
|
key=""
|
|
52
54
|
>
|
|
53
|
-
<th
|
|
55
|
+
<th
|
|
56
|
+
className={`dayTh ${props.groupsColsClassName}`}
|
|
57
|
+
style={{ ...props.groupsColsStyle }}
|
|
58
|
+
>
|
|
54
59
|
<GroupsHeadContainer
|
|
55
60
|
className={`${props.groupHeadContainerClassName}`}
|
|
56
61
|
style={props.groupHeadContainerStyle}
|
|
@@ -75,7 +80,10 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
75
80
|
/>
|
|
76
81
|
</th>
|
|
77
82
|
))}
|
|
78
|
-
<th
|
|
83
|
+
<th
|
|
84
|
+
className={`totalTh ${props.hoursColsClassName}`}
|
|
85
|
+
style={props.hoursColsStyle}
|
|
86
|
+
>
|
|
79
87
|
<SumHoursHead
|
|
80
88
|
className={props.sumHoursHeadClassName}
|
|
81
89
|
style={props.sumHoursHeadStyle}
|
|
@@ -97,8 +105,8 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
97
105
|
style={{ ...groupTdStyle, ...props.groupsColsStyle }}
|
|
98
106
|
>
|
|
99
107
|
<GroupContainer
|
|
100
|
-
style={props.
|
|
101
|
-
className={props.
|
|
108
|
+
style={props.groupContainerStyle}
|
|
109
|
+
className={props.groupContainerClassName}
|
|
102
110
|
groupRender={props.groupRender}
|
|
103
111
|
currentGroup={group}
|
|
104
112
|
handleClickGroup={props.handleClickGroup}
|
|
@@ -128,6 +136,8 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
128
136
|
);
|
|
129
137
|
}}
|
|
130
138
|
id={`td-${group.id}day-i`}
|
|
139
|
+
className={props.dayColsClassName}
|
|
140
|
+
style={props.dayColsStyle}
|
|
131
141
|
>
|
|
132
142
|
<div
|
|
133
143
|
key={positionDay}
|
|
@@ -141,8 +151,8 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
141
151
|
>
|
|
142
152
|
<>
|
|
143
153
|
{props.tasks
|
|
144
|
-
|
|
145
|
-
(
|
|
154
|
+
.map((task, taskKey) => {
|
|
155
|
+
if (
|
|
146
156
|
task.dayIndex === positionDay &&
|
|
147
157
|
task.groupId === group.id &&
|
|
148
158
|
compareWeekOffset(
|
|
@@ -150,21 +160,20 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
150
160
|
props.weekOffset || 0,
|
|
151
161
|
task.taskDate
|
|
152
162
|
)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
);
|
|
163
|
+
) {
|
|
164
|
+
return (
|
|
165
|
+
<TaskContainer
|
|
166
|
+
key={`${taskKey} task`}
|
|
167
|
+
handleDragTask={props.handleDragTask}
|
|
168
|
+
taskRender={props.taskRender}
|
|
169
|
+
handleDragTaskEnd={props.handleDragTaskEnd}
|
|
170
|
+
style={props.taskContainerStyle}
|
|
171
|
+
className={`${props.taskContainerClassName}`}
|
|
172
|
+
currentTask={task}
|
|
173
|
+
handleClickTask={props.handleClickTask}
|
|
174
|
+
/>
|
|
175
|
+
);
|
|
176
|
+
} else return "";
|
|
168
177
|
})}
|
|
169
178
|
</>
|
|
170
179
|
|
|
@@ -179,7 +188,11 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
179
188
|
</div>
|
|
180
189
|
</td>
|
|
181
190
|
))}
|
|
182
|
-
<td
|
|
191
|
+
<td
|
|
192
|
+
key={`${i}sumHours`}
|
|
193
|
+
style={props.hoursColsStyle}
|
|
194
|
+
className={props.hoursColsClassName}
|
|
195
|
+
>
|
|
183
196
|
<SumHoursContainer
|
|
184
197
|
groupId={group.id}
|
|
185
198
|
tasks={props.tasks}
|
|
@@ -204,16 +217,13 @@ function CalendarTable(props: CalendarTablePropsType) {
|
|
|
204
217
|
}
|
|
205
218
|
|
|
206
219
|
export default memo(
|
|
207
|
-
|
|
208
|
-
CalendarTable,
|
|
220
|
+
CalendarForWeek,
|
|
209
221
|
(
|
|
210
222
|
prevProps: Readonly<CalendarPropsType>,
|
|
211
223
|
nextProps: Readonly<CalendarPropsType>
|
|
212
224
|
) =>
|
|
213
|
-
|
|
214
225
|
prevProps.tasks === nextProps.tasks &&
|
|
215
226
|
prevProps.date === nextProps.date &&
|
|
216
227
|
prevProps.groups === nextProps.groups &&
|
|
217
228
|
prevProps.weekOffset === nextProps.weekOffset
|
|
218
|
-
|
|
219
229
|
);
|