2024-07-23 00:09:03 +03:30
|
|
|
|
import PropTypes from "prop-types";
|
2026-01-12 23:57:39 +00:00
|
|
|
|
import NotFoundSvg from "@/assets/Images/sushi_404.svg";
|
2024-08-31 17:37:55 -04:00
|
|
|
|
import { Button, Stack, Typography } from "@mui/material";
|
2025-06-18 10:52:11 +08:00
|
|
|
|
import { useNavigate } from "react-router-dom";
|
2024-08-28 10:28:02 -04:00
|
|
|
|
import { useTheme } from "@emotion/react";
|
2025-03-17 01:16:42 +05:30
|
|
|
|
import { useTranslation } from "react-i18next";
|
2024-05-06 12:29:36 -04:00
|
|
|
|
|
2024-07-23 00:09:03 +03:30
|
|
|
|
/**
|
|
|
|
|
|
* Support for defaultProps will be removed from function components in a future major release
|
|
|
|
|
|
* So That why we're using JavaScript default parameters instead.
|
|
|
|
|
|
*/
|
|
|
|
|
|
const DefaultValue = {
|
2024-10-17 12:05:06 +08:00
|
|
|
|
title: "Oh no! You dropped your sushi!",
|
|
|
|
|
|
desc: "Either the URL doesn’t exist, or you don’t have access to it.",
|
2024-07-23 00:09:03 +03:30
|
|
|
|
};
|
2024-05-06 12:29:36 -04:00
|
|
|
|
|
2024-07-23 00:09:03 +03:30
|
|
|
|
/**
|
|
|
|
|
|
* Renders an error page component with a customizable title and description.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @component
|
|
|
|
|
|
* @example
|
|
|
|
|
|
* // Usage:
|
|
|
|
|
|
* <ErrorPage
|
|
|
|
|
|
* title="Page Not Found"
|
|
|
|
|
|
* desc="The requested page could not be found."
|
|
|
|
|
|
* />
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param {Object} props - The component props.
|
2024-08-16 19:30:37 -07:00
|
|
|
|
* @param {string} [props.title="Oh no! You dropped your sushi!"] - The title of the error page.
|
2024-07-23 00:09:03 +03:30
|
|
|
|
* @param {string} [props.desc="Either the URL doesn’t exist, or you don’t have access to it."] - The description of the error page.
|
|
|
|
|
|
* @returns {JSX.Element} The rendered error page component.
|
|
|
|
|
|
*/
|
|
|
|
|
|
const NotFound = ({ title = DefaultValue.title, desc = DefaultValue.desc }) => {
|
2024-10-17 12:05:06 +08:00
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
const theme = useTheme();
|
2025-03-17 01:16:42 +05:30
|
|
|
|
const { t } = useTranslation();
|
2024-08-28 10:28:02 -04:00
|
|
|
|
|
2024-10-17 12:05:06 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Stack
|
|
|
|
|
|
height="100vh"
|
|
|
|
|
|
justifyContent="center"
|
|
|
|
|
|
>
|
|
|
|
|
|
<Stack
|
|
|
|
|
|
gap={theme.spacing(2)}
|
|
|
|
|
|
alignItems="center"
|
|
|
|
|
|
>
|
|
|
|
|
|
<img
|
|
|
|
|
|
src={NotFoundSvg}
|
|
|
|
|
|
alt="404"
|
|
|
|
|
|
style={{ maxHeight: "25rem" }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Typography
|
|
|
|
|
|
component="h1"
|
|
|
|
|
|
variant="h1"
|
|
|
|
|
|
fontSize={16}
|
|
|
|
|
|
>
|
|
|
|
|
|
{title}
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
<Typography variant="body1">{desc}</Typography>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
variant="contained"
|
2025-01-14 08:09:03 -05:00
|
|
|
|
color="accent"
|
2024-10-17 12:05:06 +08:00
|
|
|
|
sx={{ mt: theme.spacing(10) }}
|
|
|
|
|
|
onClick={() => navigate("/")}
|
|
|
|
|
|
>
|
2025-03-17 01:16:42 +05:30
|
|
|
|
{t("notFoundButton")}
|
2024-10-17 12:05:06 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
</Stack>
|
|
|
|
|
|
);
|
2024-07-23 00:09:03 +03:30
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
NotFound.propTypes = {
|
2024-10-17 12:05:06 +08:00
|
|
|
|
title: PropTypes.string,
|
|
|
|
|
|
desc: PropTypes.string,
|
2024-07-23 00:09:03 +03:30
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default NotFound;
|