-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.js
43 lines (34 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
import "./index.scss"
import { createRoot } from "react-dom/client"
import { Absences } from "./absences"
function getDateList(start, end) {
const list = []
let currentDate = start
while (currentDate <= end) {
list.push(currentDate)
// create a new (duplicate) date object so the new one can be altered without changing the first one
currentDate = new Date(currentDate.getTime())
currentDate.setDate(currentDate.getDate() + 1)
}
list.push(currentDate) // we need one more date for one more column grid line
return list
}
document.addEventListener("DOMContentLoaded", () => {
const { absencesByPerson, reasonList, timeBoundaries } = JSON.parse(
document.getElementById("absences-data").textContent,
)
const dateList = getDateList(
new Date(timeBoundaries.start),
new Date(timeBoundaries.end),
)
const el = document.querySelector("#absences-root")
const root = createRoot(el)
root.render(
<Absences
absencesByPerson={absencesByPerson}
timeBoundaries={timeBoundaries}
dateList={dateList}
reasonList={reasonList}
/>,
)
})