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/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