import React, { useContext, useEffect, useState } from 'react'; import { useNavigate, Link } from 'react-router-dom'; import axios from 'axios'; import { UserContext} from '../context/UserContext'; import './home.css'; function Home({ isLoggedIn, setIsLoggedIn }) { const navigate = useNavigate(); const [games, setGames] = useState([]); const { userId, username } = useContext(UserContext); useEffect(() => { if (isLoggedIn && userId) { axios.get(`http://localhost:5000/games/${userId}`) .then(response => { setGames(response.data); }) .catch(error => { console.error('Error fetching games:', error); }); } }, [isLoggedIn, userId]); const handleLogout = () => { setIsLoggedIn(false); }; return (

Willkommen zum P&P Manager {username}!

{!isLoggedIn ? (
) : (

Deine Spiele:

{games.map(game => ( ))}
Game ID Name Beschreibung
{game.game_id} {game.name} {game.description}
)}
); } export default Home;