Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x 8x 8x 8x 8x 8x 8x 2x 8x | import { Divider, Typography } from "@material-ui/core"; import classNames from "classnames"; import Alert from "components/Alert"; import HtmlMeta from "components/HtmlMeta"; import StyledLink from "components/StyledLink"; import { Trans, useTranslation } from "i18n"; import { AUTH, GLOBAL } from "i18n/namespaces"; import { useRouter } from "next/router"; import { useEffect } from "react"; import vercelLogo from "resources/vercel.svg"; import { dashboardRoute, signupRoute } from "routes"; import stringOrFirstString from "utils/stringOrFirstString"; import { useAuthContext } from "../AuthProvider"; import useAuthStyles from "../useAuthStyles"; import LoginForm from "./LoginForm"; export default function Login() { const { t } = useTranslation([AUTH, GLOBAL]); const { authState } = useAuthContext(); const authenticated = authState.authenticated; const error = authState.error; const router = useRouter(); const from = stringOrFirstString(router.query.from) ?? dashboardRoute; const redirectTo = from === "/" || from === "%2F" ? dashboardRoute : from; const authClasses = useAuthStyles(); useEffect(() => { Iif (authenticated) { router.push(redirectTo); } }, [authenticated, router, redirectTo]); return ( <> <HtmlMeta title={t("auth:login_page.title")} /> <div className={classNames(authClasses.page, authClasses.pageBackground)}> <div className={authClasses.content}> <div className={authClasses.introduction}> <Typography classes={{ root: authClasses.title }} variant="h1" component="span" > {t("auth:introduction_title")} </Typography> <Typography classes={{ root: authClasses.subtitle }} variant="h2" component="span" > {t("auth:introduction_subtitle")} <Divider className={authClasses.underline}></Divider> </Typography> </div> <div className={authClasses.formWrapper}> <Typography variant="h1" gutterBottom> {t("auth:login_page.header")} </Typography> {error && ( <Alert className={authClasses.errorMessage} severity="error"> {error} </Alert> )} <LoginForm /> <Typography> <Trans t={t} i18nKey="auth:login_page.no_account_prompt"> No account yet?{" "} <StyledLink href={signupRoute}>Sign up</StyledLink> </Trans> </Typography> </div> </div> {process.env.NEXT_PUBLIC_COUCHERS_ENV !== "prod" && ( <a className={authClasses.vercelLink} rel="noopener noreferrer" href="https://vercel.com?utm_source=couchers-org&utm_campaign=oss" > <img alt={t("auth:vercel_logo_alt_text")} src={vercelLogo.src} /> </a> )} </div> </> ); } |