From 880ed701d5ae3f3b21b30d3b9e2db5d98d6b9513 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 3 Sep 2020 18:56:40 +0800 Subject: Move AppBar to App . --- Timeline/ClientApp/src/app/views/login/index.tsx | 151 +++++++++++------------ 1 file changed, 74 insertions(+), 77 deletions(-) (limited to 'Timeline/ClientApp/src/app/views/login') diff --git a/Timeline/ClientApp/src/app/views/login/index.tsx b/Timeline/ClientApp/src/app/views/login/index.tsx index 545fc05a..a3071264 100644 --- a/Timeline/ClientApp/src/app/views/login/index.tsx +++ b/Timeline/ClientApp/src/app/views/login/index.tsx @@ -1,7 +1,7 @@ -import React, { Fragment, useState, useEffect } from "react"; +import React from "react"; import { useHistory } from "react-router"; import { useTranslation } from "react-i18next"; -import { Form, Spinner, Button } from "react-bootstrap"; +import { Form } from "react-bootstrap"; import { useUser, userService } from "@/services/user"; @@ -11,17 +11,17 @@ import LoadingButton from "../common/LoadingButton"; const LoginPage: React.FC = (_) => { const { t } = useTranslation(); const history = useHistory(); - const [username, setUsername] = useState(""); - const [usernameDirty, setUsernameDirty] = useState(false); - const [password, setPassword] = useState(""); - const [passwordDirty, setPasswordDirty] = useState(false); - const [rememberMe, setRememberMe] = useState(true); - const [process, setProcess] = useState(false); - const [error, setError] = useState(null); + const [username, setUsername] = React.useState(""); + const [usernameDirty, setUsernameDirty] = React.useState(false); + const [password, setPassword] = React.useState(""); + const [passwordDirty, setPasswordDirty] = React.useState(false); + const [rememberMe, setRememberMe] = React.useState(true); + const [process, setProcess] = React.useState(false); + const [error, setError] = React.useState(null); const user = useUser(); - useEffect(() => { + React.useEffect(() => { if (user != null) { const id = setTimeout(() => history.push("/"), 3000); return () => { @@ -72,73 +72,70 @@ const LoginPage: React.FC = (_) => { } return ( - - -
-

{t("welcome")}

-
- - {t("user.username")} - { - setUsername(e.target.value); - setUsernameDirty(true); - }} - value={username} - isInvalid={usernameDirty && username === ""} - /> - {usernameDirty && username === "" && ( - - {t("login.emptyUsername")} - - )} - - - {t("user.password")} - { - setPassword(e.target.value); - setPasswordDirty(true); - }} - value={password} - isInvalid={passwordDirty && password === ""} - /> - {passwordDirty && password === "" && ( - - {t("login.emptyPassword")} - - )} - - - - id="remember-me" - type="checkbox" - checked={rememberMe} - onChange={(e) => { - setRememberMe(e.target.checked); - }} - label={t("user.rememberMe")} - /> - - {error ?

{t(error)}

: null} -
- - {t("user.login")} - -
-
-
-
+
+

{t("welcome")}

+
+ + {t("user.username")} + { + setUsername(e.target.value); + setUsernameDirty(true); + }} + value={username} + isInvalid={usernameDirty && username === ""} + /> + {usernameDirty && username === "" && ( + + {t("login.emptyUsername")} + + )} + + + {t("user.password")} + { + setPassword(e.target.value); + setPasswordDirty(true); + }} + value={password} + isInvalid={passwordDirty && password === ""} + /> + {passwordDirty && password === "" && ( + + {t("login.emptyPassword")} + + )} + + + + id="remember-me" + type="checkbox" + checked={rememberMe} + onChange={(e) => { + setRememberMe(e.target.checked); + }} + label={t("user.rememberMe")} + /> + + {error ?

{t(error)}

: null} +
+ + {t("user.login")} + +
+
+
); }; -- cgit v1.2.3