remove favorite team now working

This commit is contained in:
Vishal Vunnam
2024-04-22 11:39:37 -06:00
parent eb779f652a
commit eef7797f57
2 changed files with 15 additions and 22 deletions

View File

@@ -9,23 +9,9 @@ document.addEventListener("DOMContentLoaded", function() {
if (favoriteButton.src.includes("/favorited.png")) {
removeFavoriteTeam(userID, teamID)
.then((rmv_status) => {
console.log(rmv_status);
if (rmv_status === 200) {
favoriteButton.src = "/img/club-page/unfavorited.png";
}
})
.catch(error => {
console.error('Error removing favorite team:', error);
});
} else {
}
else {
addFavoriteTeam(userID, teamID, teamName, teamLogo)
.then(() => {
favoriteButton.src = "/img/club-page/favorited.png";
})
.catch(error => {
console.error('Error adding favorite team:', error);
});
}
});
}
@@ -49,8 +35,11 @@ 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";
} catch (error) {
console.error('Error adding favorite team:', error);
@@ -69,6 +58,10 @@ async function removeFavoriteTeam(userID, teamID) {
})
});
console.log('Favorite team removed successfully.');
//Change button source//
var favoriteButton = document.getElementById("club-favorite-button");
favoriteButton.src = "/img/club-page/unfavorited.png";
} catch (error) {
console.error('Error removing favorite team:', error);
}