about summary refs log tree commit diff
path: root/website/habitgarden/src/App.tsx
blob: 7086c20b8e863c628da0acd6ae14ea660d44f143 (plain) (blame)
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
import React, { useEffect } from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import { useDispatch } from "react-redux";
import { actions, useTypedSelector } from "./store";
import { Link } from "react-router-dom";

const CircleRow = (props: { count: number }) => (
  <tr>
    {Array.from(Array(props.count)).map((_, i) => (
      <td key={i} className="text-center px-3 py-2">
        <input type="radio" />
      </td>
    ))}
  </tr>
);

const CircleGrid = (props: { label: string; columns: string[] }) => (
  <div>
    <h1 className="text-center text-2xl py-4">{props.label}</h1>
    <table className="mx-auto">
      <thead>
        <tr>
          {props.columns.map((x) => (
            <th key={x}>{x}</th>
          ))}
        </tr>
      </thead>
      <tbody>
        {Array.from(Array(props.columns.length)).map((_, i) => (
          <CircleRow key={i} count={props.columns.length} />
        ))}
      </tbody>
    </table>
  </div>
);

const App: React.FC = () => {
  const dispatch = useDispatch();
  const { isLoading } = useTypedSelector((state) => ({
    isLoading: state.isLoading,
  }));

  return (
    <Router>
      <Switch>
        <Route exact path="/">
          <CircleGrid label="Meditation" columns={["M", "T", "W", "Th", "F"]} />
          <CircleGrid label="Reading" columns={["M", "T", "W", "Th", "F"]} />
          <CircleGrid label="Challenge" columns={["M", "T", "W", "Th", "F"]} />
          <CircleGrid label="Jiu Jitsu" columns={["S", "M", "T"]} />
        </Route>
      </Switch>
    </Router>
  );
};

export default App;