|
1 | | -import ListItem from '@material-ui/core/ListItem'; |
| 1 | +import Box from '@material-ui/core/Box'; |
2 | 2 | import Typography from '@material-ui/core/Typography'; |
3 | | -import withWidth, { isWidthUp, WithWidthProps } from '@material-ui/core/withWidth'; |
| 3 | +import styled from 'react-emotion'; |
4 | 4 | import React, { useCallback } from 'react'; |
5 | | -import { RouteComponentProps, withRouter } from 'react-router-dom'; |
| 5 | +import { useHistory } from 'react-router-dom'; |
| 6 | + |
| 7 | +import Button from '../../muiComponents/Button'; |
| 8 | +import colors from '../../utils/styles/colors'; |
| 9 | +import { spacings } from '../../utils/styles/spacings'; |
6 | 10 |
|
7 | 11 | import PackageImg from './img/package.svg'; |
8 | | -import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles'; |
9 | 12 |
|
10 | | -export const NOT_FOUND_TEXT = `Sorry, we couldn't find it...`; |
11 | | -export const LABEL_NOT_FOUND = `The page you're looking for doesn't exist.`; |
12 | | -export const LABEL_FOOTER_NOT_FOUND = 'Perhaps these links will help find what you are looking for:'; |
| 13 | +export const NOT_FOUND_TEXT = "Sorry, we couldn't find it..."; |
| 14 | +export const LABEL_NOT_FOUND = "The page you're looking for doesn't exist."; |
| 15 | +export const GO_TO_HOME_PAGE = 'Go to the home page'; |
13 | 16 |
|
14 | | -export type NotFoundProps = RouteComponentProps & WithWidthProps; |
| 17 | +const EmptyPackage = styled('img')({ |
| 18 | + width: '150px', |
| 19 | + margin: '0 auto', |
| 20 | +}); |
15 | 21 |
|
16 | | -const HOME_LABEL = 'Home'; |
| 22 | +const StyledHeading = styled(Typography)({ |
| 23 | + color: colors.primary, |
| 24 | + marginBottom: spacings.sm, |
| 25 | +}); |
17 | 26 |
|
18 | | -const renderSubTitle = (): JSX.Element => ( |
19 | | - <Typography variant="subtitle1"> |
20 | | - <div>{LABEL_NOT_FOUND}</div> |
21 | | - <div>{LABEL_FOOTER_NOT_FOUND}</div> |
22 | | - </Typography> |
23 | | -); |
| 27 | +const NotFound: React.FC = () => { |
| 28 | + const history = useHistory(); |
24 | 29 |
|
25 | | -const NotFound: React.FC<NotFoundProps> = ({ history, width }) => { |
26 | 30 | const handleGomHome = useCallback(() => { |
27 | 31 | history.push('/'); |
28 | 32 | }, [history]); |
29 | 33 |
|
30 | | - const renderList = (): JSX.Element => ( |
31 | | - <List> |
32 | | - <ListItem button={true} divider={true} onClick={handleGomHome}> |
33 | | - {HOME_LABEL} |
34 | | - </ListItem> |
35 | | - </List> |
36 | | - ); |
37 | | - |
38 | | - /* eslint-disable @typescript-eslint/no-non-null-assertion */ |
39 | 34 | return ( |
40 | | - <Wrapper data-testid="404"> |
41 | | - <Inner> |
42 | | - <EmptyPackage alt="404 - Page not found" src={PackageImg} /> |
43 | | - <Heading className="not-found-text" variant={isWidthUp('sm', width!) ? 'h2' : 'h4'}> |
44 | | - {NOT_FOUND_TEXT} |
45 | | - </Heading> |
46 | | - {renderSubTitle()} |
47 | | - <Card>{renderList()}</Card> |
48 | | - </Inner> |
49 | | - </Wrapper> |
| 35 | + <Box alignItems="center" data-testid="404" display="flex" flexDirection="column" flexGrow={1} justifyContent="center" p={2}> |
| 36 | + <EmptyPackage alt="404 - Page not found" src={PackageImg} /> |
| 37 | + <StyledHeading className="not-found-text" variant="h4"> |
| 38 | + {NOT_FOUND_TEXT} |
| 39 | + </StyledHeading> |
| 40 | + <Button onClick={handleGomHome} variant="contained"> |
| 41 | + {GO_TO_HOME_PAGE} |
| 42 | + </Button> |
| 43 | + </Box> |
50 | 44 | ); |
51 | 45 | }; |
52 | 46 |
|
53 | | -export default withRouter<NotFoundProps, React.ComponentType<NotFoundProps>>(withWidth()(NotFound)); |
| 47 | +export default NotFound; |
0 commit comments