diff --git a/ProjectSourceCode/src/index.js b/ProjectSourceCode/src/index.js index 7894c9b..e04f54a 100644 --- a/ProjectSourceCode/src/index.js +++ b/ProjectSourceCode/src/index.js @@ -303,6 +303,7 @@ app.post('/favteam/add', async (req, res, next) => { return res.status(500).json({ error: 'Error adding favorite team' }); } }); + app.post('/favteam/remove', async (req, res) => { try { const { userID, teamID } = req.body; @@ -355,7 +356,6 @@ async function getFavoriteTeamsForUser(userId) { } } - // ***************************************************** // // ***************************************************** diff --git a/ProjectSourceCode/src/resources/css/generated-pages/club-pages/club-page-styling.css b/ProjectSourceCode/src/resources/css/generated-pages/club-pages/club-page-styling.css index c421220..596d237 100644 --- a/ProjectSourceCode/src/resources/css/generated-pages/club-pages/club-page-styling.css +++ b/ProjectSourceCode/src/resources/css/generated-pages/club-pages/club-page-styling.css @@ -15,4 +15,9 @@ #club-favorite-button:hover { cursor: pointer; +} + +#competition-logo { + width: 60px; + margin-right: 10px; } \ No newline at end of file diff --git a/ProjectSourceCode/src/resources/css/navigation-bar/navigation-bar.css b/ProjectSourceCode/src/resources/css/navigation-bar/navigation-bar.css index d87951c..505c36a 100644 --- a/ProjectSourceCode/src/resources/css/navigation-bar/navigation-bar.css +++ b/ProjectSourceCode/src/resources/css/navigation-bar/navigation-bar.css @@ -33,6 +33,27 @@ font-size: 30px; } +#favorite-teams-container { + margin-right: 25px; + + a { + text-decoration: none; + } + + img { + width: 28px; + height: auto; + margin: 0 4px; + cursor: pointer; + + transition: width 0.3s ease; /* Adding transition for smooth effect */ + } + + img:hover { + width: 32px; + } +} + #user { width: 25px; cursor: pointer; diff --git a/ProjectSourceCode/src/resources/css/navigation-bar/scoreboard-header/game-card.css b/ProjectSourceCode/src/resources/css/navigation-bar/scoreboard-header/game-card.css index 111da45..f9452c2 100644 --- a/ProjectSourceCode/src/resources/css/navigation-bar/scoreboard-header/game-card.css +++ b/ProjectSourceCode/src/resources/css/navigation-bar/scoreboard-header/game-card.css @@ -13,7 +13,6 @@ overflow: hidden; /* Hide the overflowing skewed content */ transform: skewX(-20deg); /* Skew the banner to create a triangular side */ transition: transform 0.3s ease, box-shadow 0.3s ease; /* Transition for smooth transformation and box-shadow */ - cursor: pointer; /* Change cursor to pointer on hover */ transition: transform 0.4s ease; /* Add transition for smooth effect */ } @@ -61,11 +60,17 @@ /* Container for each team in card's information */ .team { - display: flex; /* Keeps all items in a row */ align-items: center; /* Center items vertically */ padding: 5px; } +.team a { + color: black; + display: flex; + text-decoration: none; + margin: 0; +} + .team p { margin: 0; /* Remove default margin */ diff --git a/ProjectSourceCode/src/resources/js/club-page/favorite-button.js b/ProjectSourceCode/src/resources/js/club-page/favorite-button.js index 5697a60..3d0651c 100644 --- a/ProjectSourceCode/src/resources/js/club-page/favorite-button.js +++ b/ProjectSourceCode/src/resources/js/club-page/favorite-button.js @@ -8,10 +8,9 @@ document.addEventListener("DOMContentLoaded", function() { var teamLogo = document.getElementById("teamLogo").value; if (favoriteButton.src.includes("/favorited.png")) { - removeFavoriteTeam(userID, teamID) - } - else { - addFavoriteTeam(userID, teamID, teamName, teamLogo) + removeFavoriteTeam(userID, teamID); + } else { + addFavoriteTeam(userID, teamID, teamName, teamLogo); } }); } @@ -35,16 +34,19 @@ async function addFavoriteTeam(userID, teamID, teamName, teamLogo){ if (!response.ok) { throw new Error('Failed to add favorite team'); } - //Changes button if favorite team is added// - console.log('New favorite team added successfully.'); - var favoriteButton = document.getElementById("club-favorite-button"); - favoriteButton.src = "/img/club-page/favorited.png"; + + if (response.status === 200) { + console.log('New favorite team added successfully.'); + var favoriteButton = document.getElementById("club-favorite-button"); + favoriteButton.src = "/img/club-page/favorited.png"; + location.reload(); // Refresh the page + } } catch (error) { console.error('Error adding favorite team:', error); - } } + async function removeFavoriteTeam(userID, teamID) { try { const response = await fetch('/favteam/remove', { @@ -57,10 +59,13 @@ async function removeFavoriteTeam(userID, teamID) { teamID: teamID }) }); - console.log('Favorite team removed successfully.'); - //Change button source// - var favoriteButton = document.getElementById("club-favorite-button"); - favoriteButton.src = "/img/club-page/unfavorited.png"; + + if (response.status === 200) { + console.log('Favorite team removed successfully.'); + var favoriteButton = document.getElementById("club-favorite-button"); + favoriteButton.src = "/img/club-page/unfavorited.png"; + location.reload(); // Refresh the page + } } catch (error) { console.error('Error removing favorite team:', error); diff --git a/ProjectSourceCode/src/resources/js/club-page/refresh-for-favorite.js b/ProjectSourceCode/src/resources/js/club-page/refresh-for-favorite.js new file mode 100644 index 0000000..e69de29 diff --git a/ProjectSourceCode/src/resources/middleware/navigation-bar/current-match-information.js b/ProjectSourceCode/src/resources/middleware/navigation-bar/current-match-information.js index 251ac68..a57a137 100644 --- a/ProjectSourceCode/src/resources/middleware/navigation-bar/current-match-information.js +++ b/ProjectSourceCode/src/resources/middleware/navigation-bar/current-match-information.js @@ -35,10 +35,12 @@ const fetchMatchesData = async (req, res, next) => { // Extract relevant data from the API response const matches = response.data.matches.map(match => ({ homeTeam: { + teamID: match.homeTeam.id, name: match.homeTeam.tla, crest: match.homeTeam.crest, }, awayTeam: { + teamID: match.awayTeam.id, name: match.awayTeam.tla, crest: match.awayTeam.crest, }, diff --git a/ProjectSourceCode/src/views/pages/clubs-page.hbs b/ProjectSourceCode/src/views/pages/clubs-page.hbs index ebb3aef..f5e1425 100644 --- a/ProjectSourceCode/src/views/pages/clubs-page.hbs +++ b/ProjectSourceCode/src/views/pages/clubs-page.hbs @@ -81,11 +81,13 @@ Name + {{#each club.runningCompetitions}} + {{name}} {{/each}} diff --git a/ProjectSourceCode/src/views/partials/footer.hbs b/ProjectSourceCode/src/views/partials/footer.hbs index dcdbd58..d652968 100644 --- a/ProjectSourceCode/src/views/partials/footer.hbs +++ b/ProjectSourceCode/src/views/partials/footer.hbs @@ -19,6 +19,6 @@ - + \ No newline at end of file diff --git a/ProjectSourceCode/src/views/partials/navigation-bar/nav.hbs b/ProjectSourceCode/src/views/partials/navigation-bar/nav.hbs index 66404ef..3c222c6 100644 --- a/ProjectSourceCode/src/views/partials/navigation-bar/nav.hbs +++ b/ProjectSourceCode/src/views/partials/navigation-bar/nav.hbs @@ -41,6 +41,14 @@ +
+ {{#each fav_teams}} + + + + {{/each}} +
+
Your Image
diff --git a/ProjectSourceCode/src/views/partials/navigation-bar/scoreboard-header/game-card.hbs b/ProjectSourceCode/src/views/partials/navigation-bar/scoreboard-header/game-card.hbs index db34089..b078c07 100644 --- a/ProjectSourceCode/src/views/partials/navigation-bar/scoreboard-header/game-card.hbs +++ b/ProjectSourceCode/src/views/partials/navigation-bar/scoreboard-header/game-card.hbs @@ -6,15 +6,19 @@
- {{ homeTeam.name }} Crest -

{{ homeTeam.name }}

-

{{ score.homeScore }}

+ + {{ homeTeam.name }} Crest +

{{ homeTeam.name }}

+

{{ score.homeScore }}

+
- {{ awayTeam.name }} Crest -

{{ awayTeam.name }}

-

{{ score.awayScore }}

+ + {{ awayTeam.name }} Crest +

{{ awayTeam.name }}

+

{{ score.awayScore }}

+