diff --git a/src/App.tsx b/src/App.tsx index 0636f08..1e6bdf5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,3 @@ - import './App.css' import LoginForm from './Pages/LoginForm/LoginForm'; import Register from './Pages/register/Register'; @@ -6,6 +5,7 @@ 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 ( @@ -17,9 +17,7 @@ function App() { }/> }/> }/> - - - + } /> ) diff --git a/src/NotFound.tsx b/src/NotFound.tsx index 900a341..0580a51 100644 --- a/src/NotFound.tsx +++ b/src/NotFound.tsx @@ -1,14 +1,28 @@ - +import React from 'react'; +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 (
-

404 NotFound

No routes matched location

- +
- ) -} + ); +}; -export default NotFound \ No newline at end of file +export default NotFound; diff --git a/src/Pages/LoginForm/LoginForm.tsx b/src/Pages/LoginForm/LoginForm.tsx index 2e66294..2fcba9a 100644 --- a/src/Pages/LoginForm/LoginForm.tsx +++ b/src/Pages/LoginForm/LoginForm.tsx @@ -35,7 +35,7 @@ const LoginForm: React.FC = (props) => { } } catch (error) { console.error('Failed to login:', error); - + navigate('/404'); } };