react-weekly-planning 1.0.27 → 1.0.29
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/components/AddTask/index.js +17 -0
- package/components/AddTask/index.tsx +39 -0
- package/components/CalendarTable.js +48 -0
- package/components/CalendarTable.tsx +219 -0
- package/components/DayContainer/index.js +15 -0
- package/components/DayContainer/index.tsx +35 -0
- package/components/GroupContainer/index.js +15 -0
- package/components/GroupContainer/index.tsx +41 -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/definitions/index.ts +24 -3
- package/hooks/useCalendarDateState.js +13 -0
- package/hooks/useCalendarDateState.ts +24 -0
- package/index.js +4 -200
- package/index.tsx +6 -568
- package/lib/slyles.js +21 -0
- package/lib/slyles.ts +25 -0
- package/lib/utils.js +98 -271
- package/lib/utils.ts +130 -378
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
import { TaskContainerPropsType } from "../../definitions";
|
|
3
|
+
import { millisecondsToDate } from "../../lib/utils";
|
|
4
|
+
|
|
5
|
+
const TaskContainer = ({
|
|
6
|
+
handleDragTask,
|
|
7
|
+
taskRender,
|
|
8
|
+
handleDragTaskEnd,
|
|
9
|
+
style,
|
|
10
|
+
className,
|
|
11
|
+
currentTask,
|
|
12
|
+
handleClickTask,
|
|
13
|
+
|
|
14
|
+
}: TaskContainerPropsType) => {
|
|
15
|
+
|
|
16
|
+
const handleDragStart = (event: React.DragEvent<HTMLDivElement>) => {
|
|
17
|
+
if (!handleDragTask) return;
|
|
18
|
+
event.dataTransfer.effectAllowed = "move";
|
|
19
|
+
event.dataTransfer.setData("text/plain", currentTask.taskId);
|
|
20
|
+
window.sessionStorage.setItem("calendardragtaskId", currentTask.taskId);
|
|
21
|
+
window.sessionStorage.setItem(
|
|
22
|
+
"calendardragtaskStart",
|
|
23
|
+
`${currentTask.taskStart}`
|
|
24
|
+
);
|
|
25
|
+
window.sessionStorage.setItem(
|
|
26
|
+
"calendardragtaskEnd",
|
|
27
|
+
`${currentTask.taskEnd}`
|
|
28
|
+
);
|
|
29
|
+
window.sessionStorage.setItem(
|
|
30
|
+
"calendardragdayIndex",
|
|
31
|
+
`${currentTask.dayIndex}`
|
|
32
|
+
);
|
|
33
|
+
handleDragTask(event, currentTask);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleDragEnd = (event: React.DragEvent<HTMLDivElement>) => {
|
|
37
|
+
if (!handleDragTaskEnd) return;
|
|
38
|
+
handleDragTaskEnd(event);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleClick = () => {
|
|
42
|
+
if (!handleClickTask) return;
|
|
43
|
+
handleClickTask(currentTask);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (taskRender) {
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
onClick={handleClick}
|
|
50
|
+
id={currentTask.taskId}
|
|
51
|
+
className={`taskContainer ${className}`}
|
|
52
|
+
style={{ ...style }}
|
|
53
|
+
draggable
|
|
54
|
+
onDragStart={handleDragStart}
|
|
55
|
+
onDragEnd={handleDragEnd}
|
|
56
|
+
>
|
|
57
|
+
{taskRender({
|
|
58
|
+
currentTask,
|
|
59
|
+
})}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
onClick={handleClick}
|
|
67
|
+
id={currentTask.taskId}
|
|
68
|
+
className={`taskContainer ${className}`}
|
|
69
|
+
style={{ ...style }}
|
|
70
|
+
draggable
|
|
71
|
+
onDragStart={handleDragStart}
|
|
72
|
+
onDragEnd={handleDragEnd}
|
|
73
|
+
>
|
|
74
|
+
<p className="tasklabel">{currentTask.task && currentTask.task}</p>
|
|
75
|
+
<p className="taskhour">
|
|
76
|
+
{currentTask.taskStart &&
|
|
77
|
+
currentTask.taskEnd &&
|
|
78
|
+
`${millisecondsToDate(currentTask.taskStart).formattedDate} - ${
|
|
79
|
+
millisecondsToDate(currentTask.taskEnd).formattedDate
|
|
80
|
+
}`}
|
|
81
|
+
</p>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default memo(TaskContainer);
|
package/definitions/index.ts
CHANGED
|
@@ -33,7 +33,7 @@ type GroupRiquiredFieldsType = {
|
|
|
33
33
|
/**
|
|
34
34
|
* Additional fields for a group.
|
|
35
35
|
*/
|
|
36
|
-
type GroupAdditionalFieldsType = Record<any,any>;
|
|
36
|
+
type GroupAdditionalFieldsType = Record<any, any>;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Fields for a group, including both required and additional fields.
|
|
@@ -310,8 +310,8 @@ export type TaskType = {
|
|
|
310
310
|
dayIndex: number;
|
|
311
311
|
/** Unique identifier for the task. */
|
|
312
312
|
taskId: string;
|
|
313
|
-
|
|
314
|
-
taskExpiryDate?:Date
|
|
313
|
+
/** This is a prop to save the date in local storage until a date of your choice */
|
|
314
|
+
taskExpiryDate?: Date;
|
|
315
315
|
};
|
|
316
316
|
|
|
317
317
|
/**
|
|
@@ -420,3 +420,24 @@ export type SumHoursContainerPropsType = {
|
|
|
420
420
|
/** Additional class names for the sum hours container. */
|
|
421
421
|
className?: string;
|
|
422
422
|
};
|
|
423
|
+
export type weekDaysType = {
|
|
424
|
+
day: string;
|
|
425
|
+
dayMonth: string;
|
|
426
|
+
dayYear: number;
|
|
427
|
+
dayOfTheMonth: number;
|
|
428
|
+
}[];
|
|
429
|
+
|
|
430
|
+
export type dailyHoursType = {
|
|
431
|
+
positionDay: number;
|
|
432
|
+
day: Date;
|
|
433
|
+
start: number;
|
|
434
|
+
end: number;
|
|
435
|
+
}[];
|
|
436
|
+
|
|
437
|
+
type AdditionalCalandarTableType = {
|
|
438
|
+
weekDays: weekDaysType;
|
|
439
|
+
dailyHours: dailyHoursType;
|
|
440
|
+
handleDragOver: (event: React.DragEvent<HTMLTableDataCellElement>) => void;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
export type CalendarTablePropsType = CalendarPropsType;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { calculerEcartSemaine, getDayHourly, getWeekDays } from "../lib/utils";
|
|
3
|
+
function useCalendarDateState(date, weekOffset) {
|
|
4
|
+
const [calendarDateState, setCalendarDateState] = useState({ dailyHours: [], weekDays: [] });
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const weekOffsetByDate = calculerEcartSemaine(date);
|
|
7
|
+
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0);
|
|
8
|
+
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0);
|
|
9
|
+
setCalendarDateState({ dailyHours: dailyHours, weekDays });
|
|
10
|
+
}, [date, weekOffset]);
|
|
11
|
+
return Object.assign({}, calendarDateState);
|
|
12
|
+
}
|
|
13
|
+
export default useCalendarDateState;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { calculerEcartSemaine, getDayHourly, getWeekDays } from "../lib/utils";
|
|
3
|
+
import { dailyHoursType, weekDaysType } from "../definitions";
|
|
4
|
+
|
|
5
|
+
function useCalendarDateState(date: Date, weekOffset: number | undefined) {
|
|
6
|
+
const [calendarDateState, setCalendarDateState] = useState<{
|
|
7
|
+
weekDays: weekDaysType;
|
|
8
|
+
dailyHours: dailyHoursType;
|
|
9
|
+
}>({ dailyHours: [], weekDays: [] });
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
|
|
13
|
+
const weekOffsetByDate = calculerEcartSemaine(date);
|
|
14
|
+
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0);
|
|
15
|
+
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0);
|
|
16
|
+
setCalendarDateState({ dailyHours: dailyHours, weekDays });
|
|
17
|
+
|
|
18
|
+
}, [date, weekOffset]);
|
|
19
|
+
|
|
20
|
+
return { ...calendarDateState };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default useCalendarDateState;
|
|
24
|
+
|
package/index.js
CHANGED
|
@@ -1,38 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import "./style.css";
|
|
14
|
-
import
|
|
15
|
-
const theadTrStyle = {
|
|
16
|
-
color: "#0f5173",
|
|
17
|
-
fontWeight: "300",
|
|
18
|
-
position: "sticky",
|
|
19
|
-
top: 0,
|
|
20
|
-
};
|
|
21
|
-
const groupTdStyle = {
|
|
22
|
-
height: "auto",
|
|
23
|
-
width: "150px",
|
|
24
|
-
};
|
|
25
|
-
const groupContainerStyle = {
|
|
26
|
-
width: "100%",
|
|
27
|
-
height: "100%",
|
|
28
|
-
display: "flex",
|
|
29
|
-
alignItems: "center",
|
|
30
|
-
justifyContent: "space-between",
|
|
31
|
-
gap: "0.75rem", // Correspond à gap-3
|
|
32
|
-
padding: "0.75rem", // Correspond à p-3
|
|
33
|
-
color: "#0f5173",
|
|
34
|
-
cursor: "pointer",
|
|
35
|
-
};
|
|
3
|
+
import CalendarTable from "./components/CalendarTable";
|
|
36
4
|
/**
|
|
37
5
|
* Calendar component to display tasks and groups in a weekly view.
|
|
38
6
|
*
|
|
@@ -78,171 +46,7 @@ const groupContainerStyle = {
|
|
|
78
46
|
* @param {Function} [props.handleClickTask] - Handler function for clicking a task.
|
|
79
47
|
* @returns {JSX.Element} The rendered Calendar component.
|
|
80
48
|
*/
|
|
81
|
-
const Calendar = (
|
|
82
|
-
|
|
83
|
-
const weekDays = getWeekDays(weekOffsetByDate || weekOffset || 0);
|
|
84
|
-
const dailyHours = getDayHourly(weekOffsetByDate || weekOffset || 0);
|
|
85
|
-
const handleDragOver = (event) => {
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
};
|
|
88
|
-
saveTasksToLocalStorage(tasks);
|
|
89
|
-
return (_jsxs("table", { className: `planningCalendar ${className}`, style: Object.assign({}, style), children: [_jsx("thead", { children: _jsxs("tr", { className: `${rowsClassName}`, style: Object.assign(Object.assign({}, theadTrStyle), rowsStyle), children: [_jsx("th", { className: "dayTh", children: _jsx(GroupsHeadContainer, { className: `${groupHeadContainerClassName}`, style: groupHeadContainerStyle, groupsHeadRender: groupsHeadRender }) }), weekDays.map((day, i) => (_jsx("th", { className: `${daysColsClassName}`, style: Object.assign({}, daysColsStyle), children: _jsx(DayContainer, { style: dayStyle, className: dayClassName, dayIndex: i, dayRender: dayRender, day: day.day, dayOfTheMonth: day.dayOfTheMonth, dayMonth: day.dayMonth, dayYear: day.dayYear }) }, i))), _jsx("th", { className: "totalTh", children: _jsx(SumHoursHead, { className: sumHoursHeadClassName, style: sumHoursHeadStyle, sumHoursHeadRender: sumHoursHeadRender }) })] }, "") }), _jsx("tbody", { children: groups === null || groups === void 0 ? void 0 : groups.map((group, i) => (_jsxs("tr", { className: `${rowsClassName}`, style: Object.assign({}, rowsStyle), children: [_jsx("td", { className: `${groupsColsClassName}`, style: Object.assign(Object.assign({}, groupTdStyle), groupsColsStyle), children: _jsx(GroupContainer, { style: groupStyle, className: groupClassName, groupRender: groupRender, currentGroup: group, handleClickGroup: handleClickGroup }) }, i), dailyHours.map((_, positionDay) => (_jsx("td", { onDragOver: handleDragOver, onDrop: (event) => {
|
|
90
|
-
if (!handleDropTask || !tasks)
|
|
91
|
-
return;
|
|
92
|
-
const dropInfo = getSessionStorageRecordForDragAndDrop(tasks, positionDay, group.id);
|
|
93
|
-
if (!dropInfo)
|
|
94
|
-
return;
|
|
95
|
-
handleDropTask(event, dropInfo.taskDropStart, dropInfo.taskDropEnd, dropInfo.taskDropDate, group.id, positionDay, dropInfo.newTask, dropInfo.newTasks);
|
|
96
|
-
}, id: `td-${group.id}day-i`, children: _jsxs("div", { style: {
|
|
97
|
-
display: "flex",
|
|
98
|
-
width: "100%",
|
|
99
|
-
height: "100%",
|
|
100
|
-
flexDirection: "column",
|
|
101
|
-
padding: "5px",
|
|
102
|
-
}, children: [_jsx(_Fragment, { children: tasks === null || tasks === void 0 ? void 0 : tasks.filter((task) => task.dayIndex === positionDay &&
|
|
103
|
-
task.groupId === group.id &&
|
|
104
|
-
compareWeekOffset(date, weekOffset || 0, task.taskDate)).sort((a, b) => a.taskStart - b.taskStart).map((task, taskKey) => {
|
|
105
|
-
return (_jsx(TaskContainer, { handleDragTask: handleDragTask, taskRender: taskRender, handleDragTaskEnd: handleDragTaskEnd, style: taskContainerStyle, className: `${taskContainerClassName}`, currentTask: task, handleClickTask: handleClickTask }, `${taskKey} task`));
|
|
106
|
-
}) }), _jsx(AddTask, { addTaskStyle: addTaskStyle, addTaskClassName: addTaskClassName, currentGroup: group, dayInfo: dailyHours[positionDay], addTaskRender: addTaskRender, handleAddTask: handleAddTask })] }, positionDay) }, `td-${group.id}day-i${positionDay}`))), _jsx("td", { children: _jsx(SumHoursContainer, { groupId: group.id, tasks: tasks, weekOffset: weekOffset || 0, calendarDate: date, sumHoursRender: sumHoursRender, sumHoursByGroups: sumHoursByGroups(group.id, tasks, weekOffset || 0, date), className: sumHoursContainerClassName, style: sumHoursContainerStyle }) }, `${i}sumHours`)] }, `${i} tr`))) })] }));
|
|
107
|
-
};
|
|
108
|
-
const SumHoursHead = ({ sumHoursHeadRender, className, style, }) => {
|
|
109
|
-
if (sumHoursHeadRender) {
|
|
110
|
-
return _jsx(_Fragment, { children: sumHoursHeadRender() });
|
|
111
|
-
}
|
|
112
|
-
return (_jsx("div", { className: `${className}`, style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), children: "Hours" }));
|
|
113
|
-
};
|
|
114
|
-
const SumHoursContainer = ({ groupId, tasks, weekOffset, calendarDate, sumHoursByGroups, sumHoursRender, className, style, }) => {
|
|
115
|
-
if (sumHoursRender) {
|
|
116
|
-
return (_jsx(_Fragment, { children: sumHoursRender({
|
|
117
|
-
groupId,
|
|
118
|
-
tasks,
|
|
119
|
-
weekOffset,
|
|
120
|
-
calendarDate,
|
|
121
|
-
sumHoursByGroups,
|
|
122
|
-
}) }));
|
|
123
|
-
}
|
|
124
|
-
return (_jsx("div", { style: Object.assign({ textAlign: "right", marginRight: "5px" }, style), className: `${className}`, children: sumHoursByGroups }));
|
|
125
|
-
};
|
|
126
|
-
const DayContainer = ({ dayIndex, dayOfTheMonth, day, dayMonth, dayYear, dayRender, className, style, }) => {
|
|
127
|
-
if (dayRender) {
|
|
128
|
-
return (_jsx(_Fragment, { children: dayRender({
|
|
129
|
-
dayIndex,
|
|
130
|
-
day,
|
|
131
|
-
dayOfTheMonth,
|
|
132
|
-
dayMonth,
|
|
133
|
-
dayYear,
|
|
134
|
-
}) }));
|
|
135
|
-
}
|
|
136
|
-
return (_jsx("div", { className: `${className}`, style: style, children: `${day}. ${dayOfTheMonth}` }));
|
|
137
|
-
};
|
|
138
|
-
const GroupContainer = ({ className, style, groupRender, currentGroup, handleClickGroup, }) => {
|
|
139
|
-
if (groupRender) {
|
|
140
|
-
return _jsx(_Fragment, { children: groupRender({ currentGroup }) });
|
|
141
|
-
}
|
|
142
|
-
const handleClick = () => {
|
|
143
|
-
if (!handleClickGroup)
|
|
144
|
-
return;
|
|
145
|
-
handleClickGroup(currentGroup);
|
|
146
|
-
};
|
|
147
|
-
return (_jsxs("div", { onClick: handleClick, className: `${className}`, style: Object.assign(Object.assign({}, groupContainerStyle), style), children: [currentGroup.imageUrl && (_jsx("img", { width: 30, height: 30, src: currentGroup.imageUrl, alt: "groupimg" })), _jsx("label", { children: currentGroup.label && currentGroup.label })] }));
|
|
148
|
-
};
|
|
149
|
-
const AddTask = ({ currentGroup, handleAddTask, addTaskRender, dayInfo, addTaskStyle, addTaskClassName, }) => {
|
|
150
|
-
if (addTaskRender) {
|
|
151
|
-
return (_jsx(_Fragment, { children: addTaskRender({
|
|
152
|
-
currentGroup,
|
|
153
|
-
dayInfo,
|
|
154
|
-
}) }));
|
|
155
|
-
}
|
|
156
|
-
const handleClick = () => {
|
|
157
|
-
if (!handleAddTask)
|
|
158
|
-
return;
|
|
159
|
-
handleAddTask(currentGroup, dayInfo);
|
|
160
|
-
};
|
|
161
|
-
return (_jsx("div", { onClick: handleClick, style: addTaskStyle, className: `addPlanStyle ${addTaskClassName}`, children: "+" }));
|
|
162
|
-
};
|
|
163
|
-
const TaskContainer = ({ handleDragTask, taskRender, handleDragTaskEnd, style, className, currentTask, handleClickTask, }) => {
|
|
164
|
-
const handleDragStart = (event) => {
|
|
165
|
-
if (!handleDragTask)
|
|
166
|
-
return;
|
|
167
|
-
event.dataTransfer.effectAllowed = "move";
|
|
168
|
-
event.dataTransfer.setData("text/plain", currentTask.taskId);
|
|
169
|
-
window.sessionStorage.setItem("calendardragtaskId", currentTask.taskId);
|
|
170
|
-
window.sessionStorage.setItem("calendardragtaskStart", `${currentTask.taskStart}`);
|
|
171
|
-
window.sessionStorage.setItem("calendardragtaskEnd", `${currentTask.taskEnd}`);
|
|
172
|
-
window.sessionStorage.setItem("calendardragdayIndex", `${currentTask.dayIndex}`);
|
|
173
|
-
handleDragTask(event, currentTask);
|
|
174
|
-
};
|
|
175
|
-
const handleDragEnd = (event) => {
|
|
176
|
-
if (!handleDragTaskEnd)
|
|
177
|
-
return;
|
|
178
|
-
handleDragTaskEnd(event);
|
|
179
|
-
};
|
|
180
|
-
const handleClick = () => {
|
|
181
|
-
if (!handleClickTask)
|
|
182
|
-
return;
|
|
183
|
-
handleClickTask(currentTask);
|
|
184
|
-
};
|
|
185
|
-
if (taskRender) {
|
|
186
|
-
return (_jsx("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: taskRender({
|
|
187
|
-
currentTask,
|
|
188
|
-
}) }));
|
|
189
|
-
}
|
|
190
|
-
return (_jsxs("div", { onClick: handleClick, id: currentTask.taskId, className: `taskContainer ${className}`, style: Object.assign({}, style), draggable: true, onDragStart: handleDragStart, onDragEnd: handleDragEnd, children: [_jsx("p", { className: "tasklabel", children: currentTask.task && currentTask.task }), _jsx("p", { className: "taskhour", children: currentTask.taskStart &&
|
|
191
|
-
currentTask.taskEnd &&
|
|
192
|
-
`${millisecondsToDate(currentTask.taskStart).formattedDate} - ${millisecondsToDate(currentTask.taskEnd).formattedDate}` })] }));
|
|
193
|
-
};
|
|
194
|
-
const GroupsHeadContainer = ({ groupsHeadRender, style, className, }) => {
|
|
195
|
-
if (groupsHeadRender) {
|
|
196
|
-
return _jsx(_Fragment, { children: groupsHeadRender() });
|
|
197
|
-
}
|
|
198
|
-
return (_jsx("div", { className: `${className}`, style: style, children: "WeeklyCalendar" }));
|
|
199
|
-
};
|
|
200
|
-
export const updateCalendarDateWithOffset = (offset, calendarDate) => {
|
|
201
|
-
const newDate = new Date(calendarDate);
|
|
202
|
-
newDate.setDate(newDate.getDate() + offset);
|
|
203
|
-
return newDate;
|
|
204
|
-
};
|
|
205
|
-
export const updateOffsetWithDateCalendar = (calendarDate) => {
|
|
206
|
-
return calculerEcartSemaine(calendarDate);
|
|
207
|
-
};
|
|
208
|
-
export const millisecondsToHours = (milliseconds) => {
|
|
209
|
-
return millisecondsToDate(milliseconds).formattedDate;
|
|
210
|
-
};
|
|
211
|
-
export const checkDuplicates = (tasks, taskStart, taskEnd, groupId) => {
|
|
212
|
-
const findDuplicates = tasks === null || tasks === void 0 ? void 0 : tasks.filter((task) => (taskStart >= task.taskStart && taskStart < task.taskEnd) ||
|
|
213
|
-
(taskEnd > task.taskStart && taskEnd < task.taskEnd) ||
|
|
214
|
-
(taskStart <= task.taskStart &&
|
|
215
|
-
taskEnd > task.taskStart &&
|
|
216
|
-
taskEnd >= task.taskEnd &&
|
|
217
|
-
taskStart <= task.taskEnd)).filter((task) => task.groupId === groupId);
|
|
218
|
-
return findDuplicates.length > 0;
|
|
219
|
-
};
|
|
220
|
-
export const getSavedTasks = () => {
|
|
221
|
-
const taskSavedString = window.localStorage.getItem("CalendarTaskSaved");
|
|
222
|
-
if (!taskSavedString) {
|
|
223
|
-
return [];
|
|
224
|
-
}
|
|
225
|
-
const tasksTable = JSON.parse(taskSavedString);
|
|
226
|
-
const savedTasks = tasksTable.map((task) => {
|
|
227
|
-
const { taskDate, taskExpiryDate } = task, rest = __rest(task, ["taskDate", "taskExpiryDate"]);
|
|
228
|
-
if (taskExpiryDate) {
|
|
229
|
-
return Object.assign({ taskDate: new Date(taskDate), taskExpiryDate: new Date(taskExpiryDate) }, rest);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
return savedTasks;
|
|
233
|
-
};
|
|
234
|
-
export const deleteTaskSaved = (taskId) => {
|
|
235
|
-
const tasksSavedString = window.localStorage.getItem("CalendarTaskSaved");
|
|
236
|
-
if (!tasksSavedString)
|
|
237
|
-
return;
|
|
238
|
-
const tasksSavedTable = JSON.parse(tasksSavedString);
|
|
239
|
-
const taskIndex = tasksSavedTable.findIndex((task) => task.taskId === taskId);
|
|
240
|
-
if (taskIndex) {
|
|
241
|
-
tasksSavedTable.splice(taskIndex, 1);
|
|
242
|
-
window.localStorage.setItem("CalendarTaskSaved", JSON.stringify(tasksSavedTable));
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
export const deleteTasksSaved = () => {
|
|
246
|
-
window.localStorage.removeItem("CalendarTaskSaved");
|
|
49
|
+
const Calendar = (props) => {
|
|
50
|
+
return (_jsx(CalendarTable, Object.assign({}, props)));
|
|
247
51
|
};
|
|
248
52
|
export default Calendar;
|