forked from lucaspatenaude/ScoreSpot
login feature is fully complete, testing is required, favorite teams database is fully functioning
This commit is contained in:
@@ -30,6 +30,23 @@
|
||||
border-color: darkred;
|
||||
color: white;
|
||||
}
|
||||
/* CSS for the account info card */
|
||||
.account-info-card {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
padding: 20px;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.info-container {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#username {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
console.log(clubData.club.club_ID);
|
||||
var favoriteButton = document.getElementById("club-favorite-button");
|
||||
if (favoriteButton) {
|
||||
favoriteButton.addEventListener("click", function() {
|
||||
if (favoriteButton.src.includes("/favorited.png")) {
|
||||
favoriteButton.src = "/img/club-page/unfavorited.png";
|
||||
removeFavoriteTeam(1, 3);
|
||||
} else {
|
||||
console.log("kjhdsgkjh");
|
||||
favoriteButton.src = "/img/club-page/favorited.png";
|
||||
addFavoriteTeam(1, 65, 'Manchester City FC', 'https://crests.football-data.org/65.png');
|
||||
addFavoriteTeam(1, 3, 'Manchester City FC', 'https://crests.football-data.org/65.png');
|
||||
|
||||
}
|
||||
});
|
||||
@@ -14,7 +17,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
});
|
||||
async function addFavoriteTeam(userID, teamID, teamName, teamLogo) {
|
||||
try {
|
||||
const response = await fetch('/courses/add', {
|
||||
console.log("yesss")
|
||||
const response = await fetch('/favteam/add', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -33,4 +37,24 @@ async function addFavoriteTeam(userID, teamID, teamName, teamLogo) {
|
||||
} catch (error) {
|
||||
console.error('Error adding favorite team:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
async function removeFavoriteTeam(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.ok) {
|
||||
throw new Error('Failed to remove favorite team');
|
||||
}
|
||||
console.log('Favorite team removed successfully.');
|
||||
} catch (error) {
|
||||
console.error('Error removing favorite team:', error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ const fetchClubsData = async (req, res, next) => {
|
||||
|
||||
// Extract relevant data from the API response
|
||||
const clubData = response.data;
|
||||
res.locals.user = users
|
||||
// res.locals.user = users
|
||||
// Attach the data to res.locals
|
||||
res.locals.club = {
|
||||
area: {
|
||||
|
||||
Reference in New Issue
Block a user