Calendar.js
962 Bytes
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
import React, { useState } from "react";
import { Navigate, Route, Routes } from "react-router-dom";
import Grid from "../components/Grid";
import Header from "../components/Header";
import "../styles/Home.css";
export const CalendarStateContext = React.createContext();
const Calendar = () => {
console.log("visit Calendar");
const session = localStorage.getItem("session");
const [state, setState] = useState({
scope: "month",
date: new Date(),
});
return (
<CalendarStateContext.Provider value={[state, setState]}>
{session ? (
<div className="Calendar">
<Header />
<Routes>
<Route path="/month/*" element={<Grid />} />
<Route path="/week/*" element={<></>} />
<Route path="/day/*" element={<></>} />
</Routes>
</div>
) : (
<Navigate to="/login" />
)}
</CalendarStateContext.Provider>
);
};
export default Calendar;