2021-12-15 02:23:49 +00:00
|
|
|
import React, { useCallback, useEffect } from "react";
|
|
|
|
import { useLocation } from "react-router-dom";
|
2021-12-11 00:42:18 +00:00
|
|
|
import styles from "./FullScreenView.module.css";
|
|
|
|
import { Header, HeaderLogo, LeftNav, RightNav } from "./Header";
|
2021-12-15 00:12:58 +00:00
|
|
|
import classNames from "classnames";
|
2021-12-15 02:23:49 +00:00
|
|
|
import { LinkButton, Button } from "./button";
|
2021-12-11 00:42:18 +00:00
|
|
|
|
2021-12-15 00:12:58 +00:00
|
|
|
export function FullScreenView({ className, children }) {
|
2021-12-11 00:42:18 +00:00
|
|
|
return (
|
2021-12-15 00:12:58 +00:00
|
|
|
<div className={classNames(styles.page, className)}>
|
2021-12-11 00:42:18 +00:00
|
|
|
<Header>
|
|
|
|
<LeftNav>
|
|
|
|
<HeaderLogo />
|
|
|
|
</LeftNav>
|
|
|
|
<RightNav />
|
|
|
|
</Header>
|
|
|
|
<div className={styles.container}>
|
|
|
|
<div className={styles.content}>{children}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function ErrorView({ error }) {
|
|
|
|
const location = useLocation();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
console.error(error);
|
|
|
|
}, [error]);
|
|
|
|
|
2021-12-15 02:23:49 +00:00
|
|
|
const onReload = useCallback(() => {
|
|
|
|
window.location = "/";
|
|
|
|
}, []);
|
|
|
|
|
2021-12-11 00:42:18 +00:00
|
|
|
return (
|
|
|
|
<FullScreenView>
|
|
|
|
<h1>Error</h1>
|
2021-12-15 02:23:49 +00:00
|
|
|
<p>{error.message}</p>
|
|
|
|
{location.pathname === "/" ? (
|
|
|
|
<Button
|
|
|
|
size="lg"
|
|
|
|
variant="default"
|
|
|
|
className={styles.homeLink}
|
|
|
|
onPress={onReload}
|
|
|
|
>
|
|
|
|
Return to home screen
|
|
|
|
</Button>
|
|
|
|
) : (
|
|
|
|
<LinkButton
|
|
|
|
size="lg"
|
|
|
|
variant="default"
|
|
|
|
className={styles.homeLink}
|
|
|
|
to="/"
|
|
|
|
>
|
2021-12-11 00:42:18 +00:00
|
|
|
Return to home screen
|
2021-12-15 02:23:49 +00:00
|
|
|
</LinkButton>
|
2021-12-11 00:42:18 +00:00
|
|
|
)}
|
|
|
|
</FullScreenView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function LoadingView() {
|
|
|
|
return (
|
|
|
|
<FullScreenView>
|
|
|
|
<h1>Loading...</h1>
|
|
|
|
</FullScreenView>
|
|
|
|
);
|
|
|
|
}
|