Skip to content

Commit 00409cb

Browse files
authored
Merge pull request #91 from kartik-212004/feature/404-page
Added 404 - page not found component with automatic redirect to Home
2 parents b81a330 + 8aac644 commit 00409cb

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

eduaid_web/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Question_Type from "./pages/Question_Type";
55
import Text_Input from "./pages/Text_Input";
66
import Output from "./pages/Output";
77
import Previous from "./pages/Previous";
8+
import NotFound from "./pages/PageNotFound";
89

910
function App() {
1011
return (
@@ -15,6 +16,7 @@ function App() {
1516
<Route path="/input" element={<Text_Input />} />
1617
<Route path="/output" element={<Output />} />
1718
<Route path="/history" element={<Previous />} />
19+
<Route path="*" element={<NotFound />} />
1820
</Routes>
1921
</BrowserRouter>
2022
);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { useEffect, useState } from 'react';
2+
import { useNavigate } from 'react-router-dom';
3+
import "../index.css";
4+
const NotFound = () => {
5+
const router = useNavigate()
6+
const [countdown, setCountdown] = useState(5);
7+
8+
useEffect(() => {
9+
const timer = setInterval(() => {
10+
setCountdown((prev) => prev - 1);
11+
}, 1000);
12+
13+
const redirect = setTimeout(() => {
14+
router('/')
15+
}, 5000);
16+
17+
return () => {
18+
clearInterval(timer);
19+
clearTimeout(redirect);
20+
};
21+
}, []);
22+
23+
return (
24+
<div className="min-h-screen flex items-center justify-center popup bg-[#02000F] bg-custom-gradient">
25+
<div className="text-center p-8 bg-gray-800 rounded-lg shadow-xl max-w-md border border-gray-700">
26+
<h1 className="text-6xl font-bold text-blue-400 mb-4">404</h1>
27+
<h2 className="text-2xl font-semibold text-gray-200 mb-4">Page Not Found</h2>
28+
<p className="text-gray-300 mb-6">
29+
Oops! The page you're looking for doesn't exist.
30+
</p>
31+
<p className="text-gray-400">
32+
Redirecting to home page in <span className="text-blue-400">{countdown}</span> seconds...
33+
</p>
34+
</div>
35+
</div>
36+
);
37+
};
38+
39+
export default NotFound;

0 commit comments

Comments
 (0)