Skip to content

Commit

Permalink
Merge branch 'remove_typescript_errors' of https://github.com/hackfor…
Browse files Browse the repository at this point in the history
…la/HomeUniteUs into remove_typescript_errors
  • Loading branch information
erikguntner committed Oct 24, 2024
2 parents 4a7142c + 8689079 commit 39e92a9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ poetry install # Installs all dependencies

poetry shell # Activates the virtual environment

fastapi run # Run the Fast API server

# If using a shell use this:
startup_scripts/entrypoint.sh # Creates test users and runs the API in developer mode

Expand Down
28 changes: 20 additions & 8 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,32 @@ import {SystemAdminDashboard} from './pages/SystemAdminDashboard';
import {enableMocking} from './utils/testing/browser';
import {useAppDispatch} from './redux/hooks/store';
import {setCredentials} from './redux/authSlice';
import NotFound from './pages/NotFound';

function HuuApp() {
const [session] = useSessionMutation({
fixedCacheKey: 'session-post',
});
const dispatch = useAppDispatch();
// signin to current session if it exists, otherwise fail silently

React.useEffect(() => {
session()
.unwrap()
.then(res => {
const {token, user} = res;
dispatch(setCredentials({user, token}));
});
}, []);
const fetchSession = async () => {
try {
const res = await session().unwrap();
const {token, user} = res || {};

if (token && user) {
dispatch(setCredentials({user, token}));
} else {
console.warn('Token or user missing in session response');
}
} catch (error) {
console.error('Failed to fetch session:', error);
}
};

fetchSession();
}, [dispatch]);

return (
<>
Expand Down Expand Up @@ -143,6 +154,7 @@ function HuuApp() {
</ProtectedRoute>
}
/>
<Route path="*" element={<NotFound />} />
</Routes>
</>
);
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/pages/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import {Link} from 'react-router-dom';

const NotFound = () => {
return (
<div style={{textAlign: 'center', marginTop: '50px'}}>
<h1>404 - Page Not Found</h1>
<p>Sorry, the page you are looking for does not exist.</p>
<Link to="/">Go Back to Home</Link>
</div>
);
};

export default NotFound;

0 comments on commit 39e92a9

Please sign in to comment.