Files
Checkmate/Client/src/Pages/NotFound/index.jsx
T

58 lines
1.9 KiB
React
Raw Normal View History

2024-07-23 00:09:03 +03:30
import Button from "../../Components/Button";
import "./index.css";
import React from "react";
import PropTypes from "prop-types";
2024-07-23 09:12:11 +03:30
import { Stack, Typography } from "@mui/material";
2024-07-26 12:39:18 -04:00
import { useNavigate } from "react-router";
2024-08-15 15:29:37 -07:00
import NotFoundSvg from "../../../src/assets/Images/sushi_404.svg";
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-08-16 19:30:37 -07:00
title: "Oh no! You dropped your sushi!",
2024-07-23 00:09:03 +03:30
desc: "Either the URL doesn’t exist, or you don’t have access to it.",
};
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-07-26 12:39:18 -04:00
const navigate = useNavigate();
2024-07-23 00:09:03 +03:30
return (
2024-07-24 09:29:15 +03:30
<Stack className="not-found-page" justifyContent="center">
<Stack gap="20px" alignItems="center">
2024-08-16 19:30:37 -07:00
<img src={NotFoundSvg} alt="404" style={{ maxHeight: "25rem" }} />
2024-07-24 09:29:15 +03:30
<Typography component="h1">{title}</Typography>
<Typography>{desc}</Typography>
<Button
label="Go to the main dashboard"
level="primary"
sx={{ mt: "24px" }}
2024-07-26 12:39:18 -04:00
onClick={() => navigate("/")}
2024-07-24 09:29:15 +03:30
/>
2024-07-23 09:12:11 +03:30
</Stack>
</Stack>
2024-07-23 00:09:03 +03:30
);
};
NotFound.propTypes = {
title: PropTypes.string,
desc: PropTypes.string,
};
export default NotFound;