Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 page #185

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-app/public/assets/not_found.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions packages/react-app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { USER_ROLES } from "./helpers/constants";
import { providerPromiseWrapper } from "./helpers/blockchainProviders";
import BlockchainProvidersContext from "./contexts/blockchainProvidersContext";
import SiteFooter from "./components/SiteFooter";
import NotFoundView from "./views/NotFoundView";

// 😬 Sorry for all the console logging
const DEBUG = true;
Expand Down Expand Up @@ -215,6 +216,12 @@ function App() {
<Route path="/activity" exact>
<ActivityView />
</Route>
<Route path="/404" exact>
<NotFoundView />
</Route>
<Route path="*">
<Redirect to="/404" />
</Route>
</Switch>
<ColorModeSwitcher />
</div>
Expand Down
3 changes: 1 addition & 2 deletions packages/react-app/src/views/ChallengeDetailView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ export default function ChallengeDetailView({ serverUrl, address, userProvider,
}, [isAnonymous, isWalletConnected, onOpen, userRole, openModalOnLoad, setOpenModalOnLoad]);

if (!challenge) {
// TODO implement a 404 page
// this looks good: https://ant.design/components/result/#components-result-demo-404
history.push("/404");
return null;
}

const handleSubmitChallengeModal = async () => {
Expand Down
29 changes: 29 additions & 0 deletions packages/react-app/src/views/NotFoundView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { Box, Button, Container, Heading, Image, Link, Text, useColorModeValue } from "@chakra-ui/react";
import { Link as RouterLink } from "react-router-dom";

export default function NotFoundView() {
const bgColor = useColorModeValue("sre.cardBackground", "sreDark.cardBackground");

return (
<Box bgColor={bgColor} py={10}>
<Container maxW="container.lg" centerContent>
<Image mb="5" src="assets/not_found.svg" maxW="300px" />
<Heading mb="3">404</Heading>
<Text
mb="5"
fontSize={{
base: "lg",
lg: "md",
}}
textAlign="center"
>
Sorry, the page you visited does not exist.
</Text>
<Link as={RouterLink} to="/">
<Button>Back Home</Button>
</Link>
</Container>
</Box>
);
}