aboutsummaryrefslogtreecommitdiff
path: root/src/index.js
blob: ed053a69206e3c5ff84ce49b3bdc0a7d338e3a69 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { useState } from 'react';
import ReactDOM from 'react-dom';

import { Box } from "@material-ui/core";
import CssBaseline from '@material-ui/core/CssBaseline';
import { ThemeProvider, makeStyles } from '@material-ui/core/styles';

import theme from "./theme";
import Header from './components/Header/Header';
import TimerPage from "./pages/TimerPage/TimerPage";
import Scoreboard from "./pages/Scoreboard/Scoreboard";


const useStyles = makeStyles(theme => ({
  root: {
  },
}));


const App = () => {

  const [page, setPage] = useState('app');
  const [recentSolutions, setRecentSolutions] = useState([]);

  const classes = useStyles();

  const getPageComponent = page => {
    switch (page) {
      case 'app':
        return (
          <TimerPage
            recentSolutions={recentSolutions}
            setRecentSolutions={setRecentSolutions}
          />
        );
      case 'scoreboard':
        return (<Scoreboard/>);
      default:
        return (
          <p>
            This text is rendered outside of <code>Header</code> component, but
            interacting with <code>Header</code> can influence content of this page!
          </p>
        )
    }
  };

  return (
    <ThemeProvider theme={theme}>
      <CssBaseline/>
      <Header page={page} setPage={setPage}/>
      <Box className={classes.root}>
        { getPageComponent(page) }
      </Box>
    </ThemeProvider>
  );
};

document.body.style.overflow = "hidden";
ReactDOM.render(<App />, document.getElementById('root'));