From ba96eb4aaa76e83532e203f4c4a57fcfa2bd95db Mon Sep 17 00:00:00 2001 From: sharmayash105 Date: Wed, 13 Apr 2022 23:35:11 +0530 Subject: [PATCH 1/2] making events recur --- src/pages/TimeTable.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/pages/TimeTable.js b/src/pages/TimeTable.js index 6fd5f1a..6bd626f 100644 --- a/src/pages/TimeTable.js +++ b/src/pages/TimeTable.js @@ -14,6 +14,8 @@ import DialogTitle from '@material-ui/core/DialogTitle'; import SnackBar from '@material-ui/core/Snackbar'; import MuiAlert from '@material-ui/lab/Alert'; import Box from '@material-ui/core/Box'; +import Checkbox from '@material-ui/core/Checkbox'; +import FormControlLabel from '@material-ui/core/FormControlLabel'; import './TimeTable.css'; @@ -104,8 +106,22 @@ function TimeTable({ eventList, handleNewCustomEvent }) { // TODO: Ensure that end date is after start date, might mess up the Calendar library otherwise const startDate = new Date(`${eventDate} ${startTime}:00`); const endDate = new Date(`${eventDate} ${endTime}:00`); + const weekly = document.getElementById('weekly_recur'); + const daily = document.getElementById('daily_recur'); + if (startDate < endDate) { handleNewCustomEvent(title, startDate, endDate); + + if (weekly.checked) { + for (let i = 0; i < 4; i += 1) { + handleNewCustomEvent(title, startDate.getDate() + 7, endDate); + } + } + if (daily.checked) { + for (let i = 1; i < 7; i += 1) { + handleNewCustomEvent(title, startDate.getDate() + i, endDate); + } + } } else { handleNewCustomEvent(title, endDate, startDate); } @@ -215,6 +231,26 @@ function TimeTable({ eventList, handleNewCustomEvent }) { }} /> + {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */} + {/* */} + + } + label="-Daily" + /> + + {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */} + {/* */} + + } + label="-Weekly" + /> +