react-weekly-planning 1.0.33 → 1.0.35

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.
Files changed (60) hide show
  1. package/{lib → dist/lib}/utils.js +0 -13
  2. package/index.js +70 -70
  3. package/package.json +1 -8
  4. package/__tests__/page.test.js +0 -106
  5. package/__tests__/page.test.tsx +0 -129
  6. package/babel.config.js +0 -1
  7. package/components/AddTask/index.tsx +0 -43
  8. package/components/CalendarForWeek.tsx +0 -233
  9. package/components/CalendarForday.tsx +0 -131
  10. package/components/DayContainer/index.tsx +0 -36
  11. package/components/GroupContainer/index.tsx +0 -42
  12. package/components/GroupsHeadContainer/index.tsx +0 -19
  13. package/components/SumHoursContainer/index.tsx +0 -39
  14. package/components/SumHoursHead/index.tsx +0 -22
  15. package/components/TaskContainer/index.tsx +0 -86
  16. package/components/TaskList/index.tsx +0 -13
  17. package/contexts/CalendarContext.tsx +0 -38
  18. package/definition.txt +0 -319
  19. package/definitions/index.ts +0 -1084
  20. package/docs/global.html +0 -4983
  21. package/docs/index.html +0 -475
  22. package/docs/index.ts.html +0 -551
  23. package/docs/scripts/app.min.js +0 -1
  24. package/docs/scripts/linenumber.js +0 -26
  25. package/docs/scripts/search.js +0 -39
  26. package/docs/styles/app.min.css +0 -1
  27. package/docs/styles/iframe.css +0 -13
  28. package/docs/styles/prettify-jsdoc.css +0 -111
  29. package/docs/styles/prettify-tomorrow.css +0 -132
  30. package/docs/styles/reset.css +0 -44
  31. package/hooks/useCalendarDateState.ts +0 -45
  32. package/index.tsx +0 -77
  33. package/jest.config.js +0 -9
  34. package/jest.config.ts +0 -10
  35. package/lib/slyles.ts +0 -25
  36. package/lib/utils.ts +0 -990
  37. package/myJsDoc.js +0 -0
  38. package/out/index.html +0 -129
  39. package/out/scripts/app.min.js +0 -1
  40. package/out/scripts/linenumber.js +0 -26
  41. package/out/scripts/search.js +0 -39
  42. package/out/styles/app.min.css +0 -1
  43. package/out/styles/iframe.css +0 -13
  44. package/out/styles/prettify-jsdoc.css +0 -111
  45. package/out/styles/prettify-tomorrow.css +0 -132
  46. package/out/styles/reset.css +0 -44
  47. /package/{components → dist/components}/AddTask/index.js +0 -0
  48. /package/{components → dist/components}/CalendarForWeek.js +0 -0
  49. /package/{components → dist/components}/CalendarForday.js +0 -0
  50. /package/{components → dist/components}/DayContainer/index.js +0 -0
  51. /package/{components → dist/components}/GroupContainer/index.js +0 -0
  52. /package/{components → dist/components}/GroupsHeadContainer/index.js +0 -0
  53. /package/{components → dist/components}/SumHoursContainer/index.js +0 -0
  54. /package/{components → dist/components}/SumHoursHead/index.js +0 -0
  55. /package/{components → dist/components}/TaskContainer/index.js +0 -0
  56. /package/{components → dist/components}/TaskList/index.js +0 -0
  57. /package/{contexts → dist/contexts}/CalendarContext.js +0 -0
  58. /package/{definitions → dist/definitions}/index.js +0 -0
  59. /package/{hooks → dist/hooks}/useCalendarDateState.js +0 -0
  60. /package/{lib → dist/lib}/slyles.js +0 -0
@@ -9,7 +9,6 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import moment from "moment";
13
12
  import dayjs from "dayjs";
14
13
  import { v4 as uuidv4 } from "uuid";
15
14
  export const DAY_IN_MILLISECONDS = 86400000;
@@ -184,18 +183,6 @@ export function calculerEcartSemaine(dateSelectionnee, timeZone) {
184
183
  * @param numeroSemaine - The week number.
185
184
  * @returns The number of weeks since the origin date.
186
185
  */
187
- function semainesDepuisOrigine(annee, numeroSemaine) {
188
- const dateActuelle = new Date();
189
- const dateOrigine = new Date(dateActuelle.getFullYear() - 2, 0, 1);
190
- const anneeOrigine = dateOrigine.getFullYear();
191
- const numeroSemaineOrigine = getWeekNumber(dateOrigine);
192
- let nombreSemaines = 0;
193
- for (let i = anneeOrigine; i < annee; i++) {
194
- nombreSemaines += moment().year(i).isoWeeksInYear();
195
- }
196
- nombreSemaines += numeroSemaine - numeroSemaineOrigine;
197
- return nombreSemaines;
198
- }
199
186
  export function getSessionStorageRecordForDragAndDrop(tasks, positionDay, dropGroupId) {
200
187
  const dragtaskId = window.sessionStorage.getItem("calendardragtaskId");
201
188
  const dragtaskStart = window.sessionStorage.getItem("calendardragtaskStart");
package/index.js CHANGED
@@ -1,70 +1,70 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import "./style.css";
3
- import CalendarForWeek from "./components/CalendarForWeek";
4
- import CalendarForDay from "./components/CalendarForday";
5
- /**
6
- * Calendar component to display tasks and groups in a weekly view.
7
- *
8
- * @param {CalendarPropsType} props - The props for the Calendar component.
9
- * @param {number} [props.weekOffset] - Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week).
10
- * @param {GroupFeildsType[]} props.groups - Array of group data to be displayed in the calendar.
11
- * @param {string} [props.className] - Additional class names for the calendar component.
12
- * @param {React.CSSProperties} [props.style] - Additional styles for the calendar component.
13
- * @param {Date} props.date - The current date to display in the calendar.
14
- * @param {(currentGroup: { currentGroup: GroupFeildsType }) => React.ReactNode} [props.groupRender] - Custom render function for a group.
15
- * @param {({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear }: { dayIndex: number; day: string; dayOfTheMonth: number; dayMonth: string; dayYear: number }) => React.ReactNode} [props.dayRender] - Custom render function for a day.
16
- * @param {(currentTask: { currentTask: TaskFeildsType }) => React.ReactNode} [props.taskRender] - Custom render function for a task.
17
- * @param {React.CSSProperties} [props.rowsStyle] - Additional styles for the rows.
18
- * @param {string} [props.rowsClassName] - Additional class names for the rows.
19
- * @param {React.CSSProperties} [props.groupsColsStyle] - Additional styles for the group columns.
20
- * @param {string} [props.groupsColsClassName] - Additional class names for the group columns.
21
- * @param {React.CSSProperties} [props.daysColsStyle] - Additional styles for the day columns.
22
- * @param {string} [props.daysColsClassName] - Additional class names for the day columns.
23
- * @param {string} [props.addTaskClassName] - Additional class names for the add-task button.
24
- * @param {React.CSSProperties} [props.addTaskStyle] - Additional styles for the add-task button.
25
- * @param {string} [props.groupContainerClassName] - Additional class names for the group containers.
26
- * @param {React.CSSProperties} [props.groupContainerStyle] - Additional styles for the group containers.
27
- * @param {string} [props.dayClassName] - Additional class names for the day elements.
28
- * @param {React.CSSProperties} [props.dayStyle] - Additional styles for the day elements.
29
- * @param {React.CSSProperties} [props.taskContainerStyle] - Additional styles for the task container.
30
- * @param {string} [props.taskContainerClassName] - Additional class names for the task container.
31
- * @param {React.CSSProperties} [props.groupHeadContainerStyle] - Additional styles for the group header container.
32
- * @param {string} [props.groupHeadContainerClassName] - Additional class names for the group header container.
33
- * @param {React.CSSProperties} [props.sumHoursContainerStyle] - Additional styles for the sum-of-hours container.
34
- * @param {string} [props.sumHoursContainerClassName] - Additional class names for the sum-of-hours container.
35
- * @param {React.CSSProperties} [props.sumHoursHeadStyle] - Additional styles for the sum-of-hours header.
36
- * @param {string} [props.sumHoursHeadClassName] - Additional class names for the sum-of-hours header.
37
- * @param {(currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void} [props.handleAddTask] - Handler function for adding a new task.
38
- * @param {({ currentGroup, dayInfo }: { currentGroup: GroupFeildsType; dayInfo: dayInfoType }) => React.ReactNode} [props.addTaskRender] - Custom render function for adding a task.
39
- * @param {TasksType} props.tasks - Array of tasks to be displayed in the calendar.
40
- * @param {(event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void} [props.handleDragTask] - Handler function for dragging a task.
41
- * @param {(event: React.DragEvent<HTMLDivElement>, taskStart: number, taskEnd: number, taskDate: Date, groupId: string, dayIndex: number, newTask: TaskFeildsType, newTasks: TasksType) => void} [props.handleDropTask] - Handler function for dropping a task.
42
- * @param {(event: React.DragEvent<HTMLDivElement>) => void} [props.handleDragTaskEnd] - Handler function for ending the drag of a task.
43
- * @param {() => React.ReactNode} [props.groupsHeadRender] - Custom render function for the groups header.
44
- * @param {({
45
- * groupId,
46
- * tasks,
47
- * weekOffset,
48
- * calendarDate,
49
- * sumHoursByGroups
50
- * }: {
51
- * groupId: string;
52
- * tasks: TasksType;
53
- * weekOffset: number;
54
- * calendarDate: Date;
55
- * sumHoursByGroups: number;
56
- * }) => React.ReactNode} [props.sumHoursRender] - Custom render function for the sum of hours.
57
- * @param {() => React.ReactNode} [props.sumHoursHeadRender] - Custom render function for the sum-of-hours header.
58
- * @param {(currentTask: TaskFeildsType) => void} [props.handleClickTask] - Handler function for clicking a task.
59
- * @param {(currentGroup: GroupFeildsType) => void} [props.handleClickGroup] - Handler function for clicking a group.
60
- * @param {0|1|2|3|4|5|6} [props.dayOffset] - Offset index for the day column (0 = first day of week, …, 6 = last day).
61
- * @param {React.CSSProperties} [props.dayColsStyle] - Additional styles for the day columns.
62
- * @param {string} [props.dayColsClassName] - Additional class names for the day columns.
63
- * @param {React.CSSProperties} [props.hoursColsStyle] - Additional styles for the hours columns.
64
- * @param {string} [props.hoursColsClassName] - Additional class names for the hours columns.
65
- */
66
- const Calendar = (props) => {
67
- return (_jsx(_Fragment, { children: props.scope === "day" ? _jsx(CalendarForDay, Object.assign({}, props)) : _jsx(CalendarForWeek, Object.assign({}, props)) }));
68
- };
69
- export default Calendar;
70
- export { CalendarForDay };
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import "./style.css";
3
+ import CalendarForWeek from "./components/CalendarForWeek";
4
+ import CalendarForDay from "./components/CalendarForday";
5
+ /**
6
+ * Calendar component to display tasks and groups in a weekly view.
7
+ *
8
+ * @param {CalendarPropsType} props - The props for the Calendar component.
9
+ * @param {number} [props.weekOffset] - Offset for the week (e.g., -7 for last week, 0 for current week, 7 for next week).
10
+ * @param {GroupFeildsType[]} props.groups - Array of group data to be displayed in the calendar.
11
+ * @param {string} [props.className] - Additional class names for the calendar component.
12
+ * @param {React.CSSProperties} [props.style] - Additional styles for the calendar component.
13
+ * @param {Date} props.date - The current date to display in the calendar.
14
+ * @param {(currentGroup: { currentGroup: GroupFeildsType }) => React.ReactNode} [props.groupRender] - Custom render function for a group.
15
+ * @param {({ dayIndex, day, dayOfTheMonth, dayMonth, dayYear }: { dayIndex: number; day: string; dayOfTheMonth: number; dayMonth: string; dayYear: number }) => React.ReactNode} [props.dayRender] - Custom render function for a day.
16
+ * @param {(currentTask: { currentTask: TaskFeildsType }) => React.ReactNode} [props.taskRender] - Custom render function for a task.
17
+ * @param {React.CSSProperties} [props.rowsStyle] - Additional styles for the rows.
18
+ * @param {string} [props.rowsClassName] - Additional class names for the rows.
19
+ * @param {React.CSSProperties} [props.groupsColsStyle] - Additional styles for the group columns.
20
+ * @param {string} [props.groupsColsClassName] - Additional class names for the group columns.
21
+ * @param {React.CSSProperties} [props.daysColsStyle] - Additional styles for the day columns.
22
+ * @param {string} [props.daysColsClassName] - Additional class names for the day columns.
23
+ * @param {string} [props.addTaskClassName] - Additional class names for the add-task button.
24
+ * @param {React.CSSProperties} [props.addTaskStyle] - Additional styles for the add-task button.
25
+ * @param {string} [props.groupContainerClassName] - Additional class names for the group containers.
26
+ * @param {React.CSSProperties} [props.groupContainerStyle] - Additional styles for the group containers.
27
+ * @param {string} [props.dayClassName] - Additional class names for the day elements.
28
+ * @param {React.CSSProperties} [props.dayStyle] - Additional styles for the day elements.
29
+ * @param {React.CSSProperties} [props.taskContainerStyle] - Additional styles for the task container.
30
+ * @param {string} [props.taskContainerClassName] - Additional class names for the task container.
31
+ * @param {React.CSSProperties} [props.groupHeadContainerStyle] - Additional styles for the group header container.
32
+ * @param {string} [props.groupHeadContainerClassName] - Additional class names for the group header container.
33
+ * @param {React.CSSProperties} [props.sumHoursContainerStyle] - Additional styles for the sum-of-hours container.
34
+ * @param {string} [props.sumHoursContainerClassName] - Additional class names for the sum-of-hours container.
35
+ * @param {React.CSSProperties} [props.sumHoursHeadStyle] - Additional styles for the sum-of-hours header.
36
+ * @param {string} [props.sumHoursHeadClassName] - Additional class names for the sum-of-hours header.
37
+ * @param {(currentGroup: GroupFeildsType, dayInfo: dayInfoType) => void} [props.handleAddTask] - Handler function for adding a new task.
38
+ * @param {({ currentGroup, dayInfo }: { currentGroup: GroupFeildsType; dayInfo: dayInfoType }) => React.ReactNode} [props.addTaskRender] - Custom render function for adding a task.
39
+ * @param {TasksType} props.tasks - Array of tasks to be displayed in the calendar.
40
+ * @param {(event: React.DragEvent<HTMLDivElement>, currentTask: TaskFeildsType) => void} [props.handleDragTask] - Handler function for dragging a task.
41
+ * @param {(event: React.DragEvent<HTMLDivElement>, taskStart: number, taskEnd: number, taskDate: Date, groupId: string, dayIndex: number, newTask: TaskFeildsType, newTasks: TasksType) => void} [props.handleDropTask] - Handler function for dropping a task.
42
+ * @param {(event: React.DragEvent<HTMLDivElement>) => void} [props.handleDragTaskEnd] - Handler function for ending the drag of a task.
43
+ * @param {() => React.ReactNode} [props.groupsHeadRender] - Custom render function for the groups header.
44
+ * @param {({
45
+ * groupId,
46
+ * tasks,
47
+ * weekOffset,
48
+ * calendarDate,
49
+ * sumHoursByGroups
50
+ * }: {
51
+ * groupId: string;
52
+ * tasks: TasksType;
53
+ * weekOffset: number;
54
+ * calendarDate: Date;
55
+ * sumHoursByGroups: number;
56
+ * }) => React.ReactNode} [props.sumHoursRender] - Custom render function for the sum of hours.
57
+ * @param {() => React.ReactNode} [props.sumHoursHeadRender] - Custom render function for the sum-of-hours header.
58
+ * @param {(currentTask: TaskFeildsType) => void} [props.handleClickTask] - Handler function for clicking a task.
59
+ * @param {(currentGroup: GroupFeildsType) => void} [props.handleClickGroup] - Handler function for clicking a group.
60
+ * @param {0|1|2|3|4|5|6} [props.dayOffset] - Offset index for the day column (0 = first day of week, …, 6 = last day).
61
+ * @param {React.CSSProperties} [props.dayColsStyle] - Additional styles for the day columns.
62
+ * @param {string} [props.dayColsClassName] - Additional class names for the day columns.
63
+ * @param {React.CSSProperties} [props.hoursColsStyle] - Additional styles for the hours columns.
64
+ * @param {string} [props.hoursColsClassName] - Additional class names for the hours columns.
65
+ */
66
+ const Calendar = (props) => {
67
+ return (_jsx(_Fragment, { children: props.scope === "day" ? _jsx(CalendarForDay, Object.assign({}, props)) : _jsx(CalendarForWeek, Object.assign({}, props)) }));
68
+ };
69
+ export default Calendar;
70
+ export { CalendarForDay };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-weekly-planning",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest --env=jsdom",
@@ -41,13 +41,8 @@
41
41
  "dependencies": {
42
42
  "@babel/types": "^7.29.0",
43
43
  "@types/babel__generator": "^7.27.0",
44
- "axios": "^1.13.6",
45
44
  "dayjs": "^1.11.19",
46
- "ical": "^0.8.0",
47
- "ics-to-json": "^2.0.2",
48
- "moment": "^2.30.1",
49
45
  "react-window": "^2.2.7",
50
- "sass": "^1.97.3",
51
46
  "ts-node": "^10.9.2",
52
47
  "uuid": "^13.0.0"
53
48
  },
@@ -60,12 +55,10 @@
60
55
  "@testing-library/jest-dom": "^6.9.1",
61
56
  "@testing-library/react": "^16.3.2",
62
57
  "@types/babel__core": "^7.20.5",
63
- "@types/ical": "^0.8.3",
64
58
  "@types/jest": "^30.0.0",
65
59
  "@types/react": "^19.2.14",
66
60
  "@types/react-window": "^2.0.0",
67
61
  "babel-jest": "^30.2.0",
68
- "docdash": "^2.0.2",
69
62
  "jest": "^30.2.0",
70
63
  "jest-environment-jsdom": "^30.2.0",
71
64
  "react": "^19.2.4",
@@ -1,106 +0,0 @@
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
- });
@@ -1,129 +0,0 @@
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];
18
-
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();
36
-
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
- };
50
-
51
- tasks.push(task);
52
-
53
- if (!event.start) return [];
54
-
55
- // Gestion des occurrences récurrentes
56
- if (event.rrule) {
57
- const occurrences = event.rrule.between(
58
- event.start,
59
- taskExpiryDate || new Date()
60
- );
61
-
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
- }
74
-
75
- return tasks;
76
- }
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";
95
- }
96
- };
97
-
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;
121
- }
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"));
129
- });
package/babel.config.js DELETED
@@ -1 +0,0 @@
1
- module.exports = {presets: ['@babel/preset-env']}
@@ -1,43 +0,0 @@
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);