Fix error screen

This commit is contained in:
Robert Long 2021-12-14 18:23:49 -08:00
parent 269d8d4729
commit 881a8a1d1f
2 changed files with 26 additions and 18 deletions

View file

@ -1,9 +1,9 @@
import React, { useEffect } from "react"; import React, { useCallback, useEffect } from "react";
import { Link, useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { ErrorMessage } from "./Input";
import styles from "./FullScreenView.module.css"; import styles from "./FullScreenView.module.css";
import { Header, HeaderLogo, LeftNav, RightNav } from "./Header"; import { Header, HeaderLogo, LeftNav, RightNav } from "./Header";
import classNames from "classnames"; import classNames from "classnames";
import { LinkButton, Button } from "./button";
export function FullScreenView({ className, children }) { export function FullScreenView({ className, children }) {
return ( return (
@ -28,14 +28,32 @@ export function ErrorView({ error }) {
console.error(error); console.error(error);
}, [error]); }, [error]);
const onReload = useCallback(() => {
window.location = "/";
}, []);
return ( return (
<FullScreenView> <FullScreenView>
<h1>Error</h1> <h1>Error</h1>
<ErrorMessage>{error.message}</ErrorMessage> <p>{error.message}</p>
{location.pathname !== "/" && ( {location.pathname === "/" ? (
<Link className={styles.homeLink} to="/"> <Button
size="lg"
variant="default"
className={styles.homeLink}
onPress={onReload}
>
Return to home screen Return to home screen
</Link> </Button>
) : (
<LinkButton
size="lg"
variant="default"
className={styles.homeLink}
to="/"
>
Return to home screen
</LinkButton>
)} )}
</FullScreenView> </FullScreenView>
); );

View file

@ -37,15 +37,5 @@
} }
.homeLink { .homeLink {
display: flex; width: 291px;
justify-content: center;
align-items: center;
padding: 8px 136px;
color: #0dbd8b;
text-decoration: none;
background: #0dbd8b;
border-radius: 8px;
color: #ffffff;
font-weight: normal;
font-size: 15px;
} }