File structure updates

This commit is contained in:
Lucas Patenaude
2024-05-03 00:41:58 -06:00
16 changed files with 436 additions and 463 deletions

View File

@@ -1,36 +1,37 @@
document.addEventListener("DOMContentLoaded", function() {
var deleteButtons = document.querySelectorAll("#account-delete-favorite-team-button-hover");
deleteButtons.forEach(function(deleteButton) {
deleteButton.addEventListener("click", function() {
var userID = deleteButton.getAttribute("userID");
var teamID = deleteButton.getAttribute("teamID");
if (deleteButton.src.includes("/delete-club-hover.png")) {
removeAccountFavoriteTeam(userID, teamID);
}
});
});
document.addEventListener("DOMContentLoaded", function () {
var deleteButtons = document.querySelectorAll(
"#account-delete-favorite-team-button-hover"
);
deleteButtons.forEach(function (deleteButton) {
deleteButton.addEventListener("click", function () {
var userID = deleteButton.getAttribute("userID");
var teamID = deleteButton.getAttribute("teamID");
if (deleteButton.src.includes("/delete-club-hover.png")) {
removeAccountFavoriteTeam(userID, teamID);
}
});
});
});
async function removeAccountFavoriteTeam(userID, teamID) {
try {
const response = await fetch('/favteam/remove', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
userID: userID,
teamID: teamID
})
});
if (response.status === 200) {
console.log('Favorite team removed successfully.');
location.reload(); // Refresh the page
}
try {
const response = await fetch("/favteam/remove", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
userID: userID,
teamID: teamID,
}),
});
} catch (error) {
console.error('Error removing favorite team:', error);
}
if (response.status === 200) {
console.log("Favorite team removed successfully.");
location.reload(); // Refresh the page
}
} catch (error) {
console.error("Error removing favorite team:", error);
}
}