|
| 1 | +// eslint-disable-next-line import/no-unresolved |
| 2 | +import { Button, IconArrowRight, IconGroup } from "hds-react"; |
| 3 | +import React, { useState } from "react"; |
| 4 | +import { useTranslation } from "react-i18next"; |
| 5 | +import styled from "styled-components"; |
| 6 | +import Footer from "../component/Footer"; |
| 7 | +import KorosHeading, { Heading } from "../component/KorosHeading"; |
| 8 | +import { useAuthState } from "../context/AuthStateContext"; |
| 9 | +import HeroImage from "../images/hero-user@1x.jpg"; |
| 10 | +import { H2 } from "../styles/typography"; |
| 11 | +import { breakpoints } from "../styles/util"; |
| 12 | + |
| 13 | +const Wrapper = styled.div``; |
| 14 | + |
| 15 | +const LoginBtn = styled(Button).attrs({ |
| 16 | + iconLeft: <IconGroup className="icon-group" />, |
| 17 | + iconRight: <IconArrowRight className="icon-arrow" />, |
| 18 | + style: { |
| 19 | + "--color-bus": "var(--color-white)", |
| 20 | + "--color": "var(--color-black)", |
| 21 | + "--background-color-focus": "var(--color-bus)", |
| 22 | + "--color-focus": "var(--color-black)", |
| 23 | + } as React.CSSProperties, |
| 24 | +})` |
| 25 | + font-family: var(--tilavaraus-admin-font-bold); |
| 26 | + font-size: var(--fontsize-heading-l); |
| 27 | + font-weight: 700; |
| 28 | + margin-top: var(--spacing-m); |
| 29 | + padding: var(--spacing-xs) var(--spacing-m) var(--spacing-xs) var(--spacing-l); |
| 30 | + transform: scale(0.5); |
| 31 | +
|
| 32 | + svg { |
| 33 | + display: flex; |
| 34 | + } |
| 35 | +
|
| 36 | + span { |
| 37 | + margin: 0 0 0 var(--spacing-s); |
| 38 | + } |
| 39 | +
|
| 40 | + .icon-group { |
| 41 | + transform: scale(1.5); |
| 42 | + } |
| 43 | +
|
| 44 | + @media (min-width: ${breakpoints.m}) { |
| 45 | + transform: scale(1); |
| 46 | + } |
| 47 | +`; |
| 48 | + |
| 49 | +const Content = styled.div` |
| 50 | + max-width: 44rem; |
| 51 | + min-height: 30rem; |
| 52 | + margin: var(--spacing-3-xl) auto var(--spacing-2-xl); |
| 53 | + padding: 0 var(--spacing-xl); |
| 54 | +
|
| 55 | + @media (min-width: ${breakpoints.m}) { |
| 56 | + text-align: center; |
| 57 | + } |
| 58 | +`; |
| 59 | + |
| 60 | +const Ingress = styled(H2)` |
| 61 | + line-height: 1.8125rem; |
| 62 | +`; |
| 63 | + |
| 64 | +function ErrorNotLoggedIn(): JSX.Element { |
| 65 | + const { t } = useTranslation(); |
| 66 | + const { authState } = useAuthState(); |
| 67 | + const [loading, setLoading] = useState(false); |
| 68 | + |
| 69 | + return ( |
| 70 | + <Wrapper> |
| 71 | + <KorosHeading heroImage={HeroImage}> |
| 72 | + <Heading>{t("common.applicationName")}</Heading> |
| 73 | + <LoginBtn |
| 74 | + isLoading={loading} |
| 75 | + onClick={() => { |
| 76 | + setLoading(true); |
| 77 | + const { login } = authState; |
| 78 | + if (login) { |
| 79 | + login(); |
| 80 | + } |
| 81 | + }} |
| 82 | + > |
| 83 | + {t("Navigation.login")} |
| 84 | + </LoginBtn> |
| 85 | + </KorosHeading> |
| 86 | + <Content> |
| 87 | + <Ingress>{t("MainLander.ingress")}</Ingress> |
| 88 | + </Content> |
| 89 | + <Footer /> |
| 90 | + </Wrapper> |
| 91 | + ); |
| 92 | +} |
| 93 | + |
| 94 | +export default ErrorNotLoggedIn; |
0 commit comments