From fdd2ace89261944684a07310f557442eb6e8ddb3 Mon Sep 17 00:00:00 2001 From: lseidel <ls250@hdm-stuttgart.de> Date: Thu, 22 Feb 2024 15:21:29 +0100 Subject: [PATCH] 22.02.2024 - Fixed Tournament Overview + Changes in UserService in Backend #22 --- .../java/hdm/mi/sthbackend/service/UserService.java | 5 ++++- .../src/features/auth/components/LoginForm.jsx | 2 +- .../src/features/auth/components/RegisterForm.jsx | 2 +- .../tournament/components/UserTournamentOverview.jsx | 11 ++--------- sth-frontend/src/layouts/Navbar.jsx | 8 +++++++- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/sth-backend/src/main/java/hdm/mi/sthbackend/service/UserService.java b/sth-backend/src/main/java/hdm/mi/sthbackend/service/UserService.java index 6dcb0b7..55ce78a 100644 --- a/sth-backend/src/main/java/hdm/mi/sthbackend/service/UserService.java +++ b/sth-backend/src/main/java/hdm/mi/sthbackend/service/UserService.java @@ -29,8 +29,11 @@ public class UserService { .findById(userId) .orElseThrow(() -> new UserNotFoundException(userId.toString())); List<UUID> tournamentIds = user.getTournamentIds(); - + if (tournamentIds == null){ + return new ArrayList<>(); + } return tournamentRepository.findAllById(tournamentIds); + } diff --git a/sth-frontend/src/features/auth/components/LoginForm.jsx b/sth-frontend/src/features/auth/components/LoginForm.jsx index 0a0c87f..19fecf9 100644 --- a/sth-frontend/src/features/auth/components/LoginForm.jsx +++ b/sth-frontend/src/features/auth/components/LoginForm.jsx @@ -21,7 +21,7 @@ const handleSubmit = async (e) => { <div className='bg-deepPurple text-lightGray m-auto w-1/2 h-full max-sm:w-full'> <div className='py-16 flex justify-around'> <button className='rounded bg-darkGray hover:scale-110'> - <Link to={'/landingpage'}> + <Link to={'/'}> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="#D9D9D9" className="w-10 h-10"> <path strokeLinecap="round" strokeLinejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5"/> diff --git a/sth-frontend/src/features/auth/components/RegisterForm.jsx b/sth-frontend/src/features/auth/components/RegisterForm.jsx index 5177b63..b5792eb 100644 --- a/sth-frontend/src/features/auth/components/RegisterForm.jsx +++ b/sth-frontend/src/features/auth/components/RegisterForm.jsx @@ -44,7 +44,7 @@ function RegisterForm() { <div className='bg-deepPurple text-lightGray m-auto w-1/2 h-full max-sm:w-full'> <div className='py-16 flex flex-row justify-around'> <button className='rounded bg-darkGray hover:scale-110'> - <Link to={'/landingpage'}> + <Link to={'/'}> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="#D9D9D9" className="w-10 h-10"> <path strokeLinecap="round" strokeLinejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5"/> diff --git a/sth-frontend/src/features/tournament/components/UserTournamentOverview.jsx b/sth-frontend/src/features/tournament/components/UserTournamentOverview.jsx index 7778169..0395e96 100644 --- a/sth-frontend/src/features/tournament/components/UserTournamentOverview.jsx +++ b/sth-frontend/src/features/tournament/components/UserTournamentOverview.jsx @@ -4,15 +4,6 @@ import {Link, useLoaderData, useParams} from "react-router-dom"; export default function UserTournamentOverview() { const {userId} = useParams() const tournaments = useLoaderData() - console.log(tournaments) - if (!tournaments) { - return ( - <div className='flex justify-center items-center'> - <h1>Oops! There are no tournaments available right now.</h1> - <h2>Please create a new tournament.</h2> - </div> - ) - } return (<div className='bg-deepPurple flex justify-center h-screen overscroll-none mx-56 p-10'> <table className=' px-16 w-full h-fit '> @@ -26,7 +17,9 @@ export default function UserTournamentOverview() { </tr> </thead> <tbody className='flex flex-col gap-4 w-full h-fit'> + {tournaments.map((tournament) => { + return ( <Link to={`/users/${userId}/tournaments/${tournament.tournamentId}`}> <tr key={tournament.tournamentId} diff --git a/sth-frontend/src/layouts/Navbar.jsx b/sth-frontend/src/layouts/Navbar.jsx index d1de623..52acb63 100644 --- a/sth-frontend/src/layouts/Navbar.jsx +++ b/sth-frontend/src/layouts/Navbar.jsx @@ -28,7 +28,6 @@ const Navbar = () => { const toggleDarkMode = () => { console.log("svgIcon: " + svgIconColor) - setDarkMode(!darkMode) }; @@ -130,6 +129,13 @@ const Navbar = () => { onClick={() => setIsOpen(true)}> Create </button> + <button className='rounded-3xl border-2 px-12 py-2 hover:bg-deepPurple'> + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} + stroke="currentColor" className="w-6 h-6"> + <path strokeLinecap="round" strokeLinejoin="round" + d="M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9"/> + </svg> + </button> </div> <div className='hidden max-sm:flex'> <button onClick={toggleUserMenu} className=''> -- GitLab