forked from lucaspatenaude/ScoreSpot
finished addfavorite team, page recognizes when team is favorited or not. remove favorite team currently not working
This commit is contained in:
@@ -9,12 +9,15 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
if (favoriteButton.src.includes("/favorited.png")) {
|
||||
removeFavoriteTeam(userID, teamID)
|
||||
.then(() => {
|
||||
.then((rmv_status) => {
|
||||
console.log(rmv_status);
|
||||
if (rmv_status === 200) {
|
||||
favoriteButton.src = "/img/club-page/unfavorited.png";
|
||||
})
|
||||
.catch(error => {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error removing favorite team:', error);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
addFavoriteTeam(userID, teamID, teamName, teamLogo)
|
||||
.then(() => {
|
||||
@@ -26,7 +29,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function addFavoriteTeam(userID, teamID, teamName, teamLogo){
|
||||
try {
|
||||
const response = await fetch('/favteam/add', {
|
||||
@@ -64,9 +68,6 @@ async function removeFavoriteTeam(userID, teamID) {
|
||||
teamID: teamID
|
||||
})
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to remove favorite team');
|
||||
}
|
||||
console.log('Favorite team removed successfully.');
|
||||
} catch (error) {
|
||||
console.error('Error removing favorite team:', error);
|
||||
|
||||
Reference in New Issue
Block a user