Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

import './App.css'
import LoginForm from './Pages/LoginForm/LoginForm';
import Register from './Pages/register/Register';
import LandingPage from './Pages/LandingPage'
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import Librarylist from './Pages/Librarylist';
import Users from './Pages/Users';
import NotFound from './NotFound';

function App() {
return (
Expand All @@ -17,9 +17,7 @@ function App() {
<Route path='/register' element={<Register/>}/>
<Route path='/librarylist' element={<Librarylist/>}/>
<Route path='/users' element={<Users/>}/>



<Route path="*" element={<NotFound />} />
</Routes>
</BrowserRouter>
)
Expand Down
26 changes: 20 additions & 6 deletions src/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@

import React from 'react';

Check failure on line 1 in src/NotFound.tsx

View workflow job for this annotation

GitHub Actions / build

'React' is declared but its value is never read.
import { useNavigate } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { Button } from '@/components/ui/button';
import { RootState } from '@/store/store';

const NotFound = () => {
const navigate = useNavigate();
const isLoggedIn = useSelector((state: RootState) => state.auth.user !== null);

const handleBack = () => {
if (isLoggedIn) {
navigate('/');
} else {
navigate('/library/login');
}
};

return (
<div className="h-[100vh] w-[100%] flex flex-col justify-center items-center ">

<h2 className="text-[128px]">404 NotFound</h2>
<p>No routes matched location </p>

<Button onClick={handleBack}>Go Back</Button>
</div>
)
}
);
};

export default NotFound
export default NotFound;
2 changes: 1 addition & 1 deletion src/Pages/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const LoginForm: React.FC<LoginFormProps> = (props) => {
}
} catch (error) {
console.error('Failed to login:', error);

navigate('/404');
}
};

Expand Down
Loading