digitransit-ui/app/component/404.js
2024-03-20 12:25:44 +02:00

71 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import Link from 'found/Link';
import { configShape } from '../util/shapes';
import Icon from './Icon';
const Error404 = (props, { config }) => {
const { error } = props;
return (
<div className="page-not-found">
<Icon img="icon-icon_error_page_not_found" />
{!error && (
<p>
<FormattedMessage
id="page-not-found"
defaultMessage="The page cannot be found."
/>
</p>
)}
{error && (
<p className="error">
<FormattedMessage
id={error.id}
values={error.values || {}}
defaultMessage="Error occured."
/>
</p>
)}
<p>
{config.URL.ROOTLINK ? (
<a href={config.URL.ROOTLINK}>
<FormattedMessage
id="back-to-front-page"
defaultMessage="Back to front page "
/>
</a>
) : (
<Link to={`/${config.indexPath}`}>
<FormattedMessage
id="back-to-front-page"
defaultMessage="Back to front page "
/>
</Link>
)}
</p>
</div>
);
};
Error404.contextTypes = {
config: configShape.isRequired,
};
Error404.propTypes = {
error: PropTypes.shape({
id: PropTypes.string,
// eslint-disable-next-line
values: PropTypes.object,
}),
};
Error404.defaultProps = {
error: undefined,
};
Error404.displayName = 'Error404';
export default Error404;