aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/home-v2/index.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-16 17:43:16 +0800
committercrupest <crupest@outlook.com>2021-04-16 17:43:16 +0800
commit3fd4375920c7692082f6e8e91d763ec5c0a1d72a (patch)
treee0523cb6c73ed1c53c99f823ebbd3395165e388d /FrontEnd/src/app/views/home-v2/index.tsx
parent9c0053cd70593bf6add0eab4dbb91a8479d56821 (diff)
downloadtimeline-3fd4375920c7692082f6e8e91d763ec5c0a1d72a.tar.gz
timeline-3fd4375920c7692082f6e8e91d763ec5c0a1d72a.tar.bz2
timeline-3fd4375920c7692082f6e8e91d763ec5c0a1d72a.zip
...
Diffstat (limited to 'FrontEnd/src/app/views/home-v2/index.tsx')
-rw-r--r--FrontEnd/src/app/views/home-v2/index.tsx101
1 files changed, 0 insertions, 101 deletions
diff --git a/FrontEnd/src/app/views/home-v2/index.tsx b/FrontEnd/src/app/views/home-v2/index.tsx
deleted file mode 100644
index cb3c1428..00000000
--- a/FrontEnd/src/app/views/home-v2/index.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import React from "react";
-import { useHistory } from "react-router";
-import { useTranslation } from "react-i18next";
-import { Container, Button, Row, Col } from "react-bootstrap";
-
-import { useUser } from "@/services/user";
-import SearchInput from "../common/SearchInput";
-
-import TimelineListView from "./TimelineListView";
-import TimelineCreateDialog from "../home/TimelineCreateDialog";
-import { HttpTimelineInfo } from "@/http/timeline";
-import { getHttpHighlightClient } from "@/http/highlight";
-
-const highlightTimelineMessageMap = {
- loading: "home.loadingHighlightTimelines",
- done: "home.loadedHighlightTimelines",
- error: "home.errorHighlightTimelines",
-} as const;
-
-const HomeV2: React.FC = () => {
- const history = useHistory();
-
- const { t } = useTranslation();
-
- const user = useUser();
-
- const [navText, setNavText] = React.useState<string>("");
-
- const [dialog, setDialog] = React.useState<"create" | null>(null);
-
- const [highlightTimelineState, setHighlightTimelineState] = React.useState<
- "loading" | "done" | "error"
- >("loading");
- const [highlightTimelines, setHighlightTimelines] = React.useState<
- HttpTimelineInfo[] | undefined
- >();
-
- React.useEffect(() => {
- if (highlightTimelineState === "loading") {
- let subscribe = true;
- void getHttpHighlightClient()
- .list()
- .then(
- (data) => {
- if (subscribe) {
- setHighlightTimelineState("done");
- setHighlightTimelines(data);
- }
- },
- () => {
- if (subscribe) {
- setHighlightTimelineState("error");
- setHighlightTimelines(undefined);
- }
- }
- );
- return () => {
- subscribe = false;
- };
- }
- }, [highlightTimelineState]);
-
- return (
- <>
- <Container fluid className="px-0">
- <Row className="mx-0 my-3 px-2 justify-content-end">
- <Col xs="12" sm="auto">
- <SearchInput
- value={navText}
- onChange={setNavText}
- onButtonClick={() => {
- history.push(`search?q=${navText}`);
- }}
- additionalButton={
- user != null && (
- <Button
- variant="outline-success"
- onClick={() => {
- setDialog("create");
- }}
- >
- {t("home.createButton")}
- </Button>
- )
- }
- />
- </Col>
- </Row>
- <TimelineListView
- headerText={highlightTimelineMessageMap[highlightTimelineState]}
- timelines={highlightTimelines}
- />
- </Container>
- {dialog === "create" && (
- <TimelineCreateDialog open close={() => setDialog(null)} />
- )}
- </>
- );
-};
-
-export default HomeV2;