aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/center/index.tsx
blob: dfad082a038bc5d57cd3497edea404798635ecc2 (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
61
62
import React from "react";
import { useHistory } from "react-router";

import { useUserLoggedIn } from "@/services/user";

import SearchInput from "../common/SearchInput";
import Button from "../common/button/Button";
import CenterBoards from "./CenterBoards";
import TimelineCreateDialog from "./TimelineCreateDialog";

import "./index.css";

const HomePage: React.FC = () => {
  const history = useHistory();

  const user = useUserLoggedIn();

  const [navText, setNavText] = React.useState<string>("");

  const [dialog, setDialog] = React.useState<"create" | null>(null);

  return (
    <>
      <div>
        <div className="row my-3 justify-content-center">
          <div className="col col-12 col-sm-8 col-lg-6">
            <SearchInput
              className="justify-content-center"
              value={navText}
              onChange={setNavText}
              onButtonClick={() => {
                history.push(`search?q=${navText}`);
              }}
              additionalButton={
                user != null && (
                  <Button
                    text="home.createButton"
                    color="success"
                    onClick={() => {
                      setDialog("create");
                    }}
                  />
                )
              }
            />
          </div>
        </div>
        <CenterBoards />
      </div>
      {dialog === "create" && (
        <TimelineCreateDialog
          open
          close={() => {
            setDialog(null);
          }}
        />
      )}
    </>
  );
};

export default HomePage;