Error page implemented
This commit is contained in:
1 parent
d541dfb57b
commit
1e5c0f05fb
3 files changed
+105
No files matched your search
@@ -20,6 +20,7 @@ import Details from "./Pages/Monitors/Details";
|
|||||||
import Maintenance from "./Pages/Maintenance";
|
import Maintenance from "./Pages/Maintenance";
|
||||||
import "react-toastify/dist/ReactToastify.css";
|
import "react-toastify/dist/ReactToastify.css";
|
||||||
import { ToastContainer } from "react-toastify";
|
import { ToastContainer } from "react-toastify";
|
||||||
|
import ErrorPage from "./Pages/Errors";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@@ -89,6 +90,7 @@ function App() {
|
|||||||
path="/new-password-confirmed"
|
path="/new-password-confirmed"
|
||||||
element={<NewPasswordConfirmed />}
|
element={<NewPasswordConfirmed />}
|
||||||
/>
|
/>
|
||||||
|
<Route exact path="/error" element={<ErrorPage />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
.error-page,
|
||||||
|
.error-template,
|
||||||
|
.error-title,
|
||||||
|
.error-description {
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-page {
|
||||||
|
display: flex;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-template {
|
||||||
|
min-height: 170px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-title,
|
||||||
|
.error-description {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-title {
|
||||||
|
font-size: var(--env-var-font-size-large);
|
||||||
|
color: var(--env-var-color-5);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-description {
|
||||||
|
font-size: var(--env-var-font-size-medium);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-page-gap-medium {
|
||||||
|
height: var(--env-var-spacing-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-page-gap-xlarge {
|
||||||
|
height: calc(var(--env-var-spacing-4) + var(--env-var-spacing-2));
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import Button from "../../Components/Button";
|
||||||
|
import "./index.css";
|
||||||
|
import React from "react";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = {
|
||||||
|
title: "We cannot find this page",
|
||||||
|
desc: "Either the URL doesn’t exist, or you don’t have access to it.",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
* @param {string} [props.title="We cannot find this page"] - The title of the error page.
|
||||||
|
* @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 ErrorPage = ({
|
||||||
|
title = DefaultValue.title,
|
||||||
|
desc = DefaultValue.desc,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div className="error-page">
|
||||||
|
<div className="error-template">
|
||||||
|
<div className="error-title">{title}</div>
|
||||||
|
<div className="error-page-gap-medium"></div>
|
||||||
|
<div className="error-description">{desc}</div>
|
||||||
|
<div className="error-page-gap-xlarge"></div>
|
||||||
|
<div
|
||||||
|
className="button-container"
|
||||||
|
style={{ display: "flex", justifyContent: "center" }}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
label="Go to the main dashboard"
|
||||||
|
level="primary"
|
||||||
|
id="error-page-action"
|
||||||
|
sx={{ fontSize: "var(--env-var-font-size-medium)" }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ErrorPage.propTypes = {
|
||||||
|
title: PropTypes.string,
|
||||||
|
desc: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ErrorPage;
|
||||||
Reference in new issue
Block a user