Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit e0621eb

Browse files
committed
change design of error page when not loggeed in
1 parent e42bda3 commit e0621eb

File tree

5 files changed

+58
-57
lines changed

5 files changed

+58
-57
lines changed

src/components/App.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { BrowserRouter, Route, Switch } from "react-router-dom";
44
import Router from "./Router/Router";
55
import PermanentAssets from "./basicElements/PermanentAssets";
66

7-
import Login from "./basicElements/login/Login";
7+
import Login, { LoginHeader } from "./basicElements/login/Login";
88
import HeadArea from "./basicElements/topArea/TopArea";
99
import BottomArea from "./basicElements/bottomArea/BottomArea";
1010

@@ -19,6 +19,7 @@ import { checkForCookie } from "../background/api/auth";
1919
import { FFLoading } from "./basicElements/Loading";
2020
import { CookieStatus } from "../background/redux/actions/tokenTypes";
2121
import Error400 from "./pages/errors/Error400";
22+
import { Container } from "react-bootstrap";
2223

2324
// this takes the redux store and maps everything that is needed to the function props
2425
const mapState = (state: SystemState) => ({
@@ -69,15 +70,20 @@ function App(props: Props): ReactElement {
6970
} else {
7071
console.log("[APP] showing login");
7172
return (
72-
<BrowserRouter>
73-
<Switch>
74-
<Route
75-
path={"/error"}
76-
component={() => <Error400 needsLogin />}
77-
/>
78-
<Route path={"*"} component={Login} />
79-
</Switch>
80-
</BrowserRouter>
73+
<Container fluid className="h-100 ml-0 mr-0 login-page">
74+
<div className="login-container pr-1 pl-1 mr-auto ml-auto">
75+
<LoginHeader />
76+
<BrowserRouter>
77+
<Switch>
78+
<Route
79+
path={"/error"}
80+
component={() => <Error400 needsLogin />}
81+
/>
82+
<Route path={"*"} component={Login} />
83+
</Switch>
84+
</BrowserRouter>
85+
</div>
86+
</Container>
8187
);
8288
}
8389
} else {

src/components/Router/Router.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ export default function Router(): ReactElement {
2121
<Route path={"/health"} component={Health} />
2222
<Route path={filesBaseUrl} component={FileSystem} />
2323
<Route path={"/registration"} component={Registration} />
24-
{<Route path={"/profile"} component={Profile} />}
25-
{<Route path={"/profile"} component={Profile} />}
26-
{<Route path={"/error"} component={Error400} />}
24+
<Route path={"/profile"} component={Profile} />
25+
<Route path={"/profile"} component={Profile} />
26+
<Route path={"/error"} component={Error400} />
27+
<Route
28+
path={["/data", "/api"]}
29+
component={() => {
30+
window.location.reload(); // leave the spa, to access the apis. This could cause a endless loop if the nginx is not present
31+
return null;
32+
}}
33+
/>
2734
<Route path={"*"} component={Error404} />
2835
</Switch>
2936
);

src/components/basicElements/login/Login.tsx

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@ import React, {
55
SetStateAction,
66
useState
77
} from "react";
8-
import {
9-
Button,
10-
Col,
11-
Container,
12-
Form,
13-
Image,
14-
Row,
15-
Spinner
16-
} from "react-bootstrap";
8+
import { Button, Col, Form, Image, Row, Spinner } from "react-bootstrap";
179
import { loginWithUsernameAndPassword } from "../../../background/api/auth";
1810

1911
import logo from "../../../assets/images/logos/logoWithWhiteBorder.png";
@@ -51,7 +43,6 @@ function Login(): ReactElement {
5143
if (tokens.refreshToken && tokens.accessToken?.token) {
5244
if (dest) {
5345
history.push(decodeURIComponent(dest));
54-
window.location.reload(); // reload because we are leaving the spa
5546
} else {
5647
history.push("/");
5748
}
@@ -73,20 +64,18 @@ function Login(): ReactElement {
7364
};
7465

7566
return (
76-
<Container fluid className="h-100 ml-0 mr-0 login-page">
77-
<LoginInteractionArea
78-
handleSubmit={handleSubmit}
79-
username={userName}
80-
setUsername={setUsername}
81-
password={password}
82-
setPassword={setPassword}
83-
isLoading={isLoading}
84-
setIsLoading={setIsLoading}
85-
stayLoggedIn={stayLoggedIn}
86-
setStayLoggedIn={setStayLoggedIn}
87-
errorMessage={errorMessage}
88-
/>
89-
</Container>
67+
<LoginInteractionArea
68+
handleSubmit={handleSubmit}
69+
username={userName}
70+
setUsername={setUsername}
71+
password={password}
72+
setPassword={setPassword}
73+
isLoading={isLoading}
74+
setIsLoading={setIsLoading}
75+
stayLoggedIn={stayLoggedIn}
76+
setStayLoggedIn={setStayLoggedIn}
77+
errorMessage={errorMessage}
78+
/>
9079
);
9180
}
9281

@@ -104,21 +93,18 @@ export function LoginInteractionArea(props: LoginInputInterface) {
10493
errorMessage
10594
} = props;
10695
return (
107-
<div className="login-container pr-1 pl-1 mr-auto ml-auto">
108-
<LoginHeader />
109-
<LoginInput
110-
handleSubmit={handleSubmit}
111-
username={username}
112-
setUsername={setUsername}
113-
password={password}
114-
setPassword={setPassword}
115-
isLoading={isLoading}
116-
setIsLoading={setIsLoading}
117-
stayLoggedIn={stayLoggedIn}
118-
setStayLoggedIn={setStayLoggedIn}
119-
errorMessage={errorMessage}
120-
/>
121-
</div>
96+
<LoginInput
97+
handleSubmit={handleSubmit}
98+
username={username}
99+
setUsername={setUsername}
100+
password={password}
101+
setPassword={setPassword}
102+
isLoading={isLoading}
103+
setIsLoading={setIsLoading}
104+
stayLoggedIn={stayLoggedIn}
105+
setStayLoggedIn={setStayLoggedIn}
106+
errorMessage={errorMessage}
107+
/>
122108
);
123109
}
124110

src/components/pages/errors/Error400.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ export default function Error400({ needsLogin }: Props) {
2020

2121
return (
2222
<Container className={"text-center"}>
23-
<h2>Something went wrong!</h2>
24-
<h3>The file could not be loaded</h3>
23+
<h2 className={"text-danger"}>Something went wrong!</h2>
24+
<h3 className="text-danger"> The file could not be loaded</h3>
2525
{message && <h4>{message}</h4>}
26-
{tryAgainUrl && <p></p>}
27-
<Link to="/">Go to Home</Link>
28-
{tryAgainUrl}
26+
{dest && tryAgainUrl}
27+
<p>
28+
<Link to="/">Go to Home</Link>
29+
</p>
2930
</Container>
3031
);
3132
}

src/style/helpers.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121

122122
.login-page {
123123
background-image: url("../assets/images/background/parallax-mountain.png");
124+
background-size: 100% auto;
124125
}
125126

126127
.login-container {

0 commit comments

Comments
 (0)