Presupuestador_web/client/src/app/ErrorPage.tsx

51 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-06-06 11:05:54 +00:00
import { Button } from "@/ui";
import { useLocation, useNavigate } from "react-router-dom";
// import Button
2024-06-06 21:07:40 +00:00
/*const isDev = process.env.REACT_APP_NODE_ENV === "development";
2024-06-06 11:05:54 +00:00
const hostname = `${
isDev ? process.env.REACT_APP_DEV_API_URL : process.env.REACT_APP_PROD_API_URL
2024-06-06 21:07:40 +00:00
}`;*/
2024-06-06 11:05:54 +00:00
type ErrorPageProps = {
error?: string;
};
export const ErrorPage = (props: ErrorPageProps) => {
const navigate = useNavigate();
const location = useLocation();
const navMsg = location.state?.error;
const msg = navMsg ? (
<p className='text-lg'>{navMsg}</p>
) : props.error ? (
<p className='text-lg'>{props.error}</p>
) : (
<p className='text-lg'>
The targeted page <b>"{location.pathname}"</b> was not found, please confirm the spelling and
try again.
</p>
);
return (
<section id='Error' className='flex flex-col items-center w-full h-full'>
{msg}
<span className='flex flex-row items-center justify-center my-10 space-x-8 '>
<Button id='backButton' onClick={() => navigate(-1)}>
Return to Previous Page
</Button>
2024-07-01 17:12:15 +00:00
<Button id='homeButton' onClick={() => navigate("/")}>
2024-06-06 11:05:54 +00:00
Return to Home Page
</Button>
<Button
id='logout'
onClick={() => {
2024-06-06 21:07:40 +00:00
//const endpoint = `${hostname}/logout`;
//window.open(endpoint, "_blank");
2024-06-06 11:05:54 +00:00
}}
>
Reset Authentication
</Button>
</span>
</section>
);
};