Updates to file structure

This commit is contained in:
Lucas Patenaude
2024-04-30 22:12:59 -06:00
parent 289e7641b4
commit bd79a6ccc3
71 changed files with 14 additions and 14 deletions

View File

@@ -0,0 +1,17 @@
const express = require('express');
const app = express();
// generate-league-routes.js
// Define a function to generate league routes
module.exports = function generateClubRoutes(app) {
// Define a route to handle requests to "/league/:leagueName"
app.get('/club/:clubID', (req, res) => {
// Extract the league name from the URL parameters
const clubID = req.params.clubID;
// Render the league page template using Handlebars
res.render('pages/club-page', { clubID: clubID, });
});
};

View File

@@ -0,0 +1,17 @@
// Add click event listener to club logos
document.querySelectorAll('#league-table-club-logo, #league-table-club-name-column, #league-top-scorers-logo, #league-top-scorers-club-name-column').forEach(element => {
element.addEventListener('click', (event) => {
// Get the club ID from the clicked club logo's clubID attribute
const clubId = element.getAttribute('clubID');
redirectToClubPage(clubId);
});
});
// Function to redirect to the club page
function redirectToClubPage(clubID) {
// Append the club ID to the URL
var url = "/club/" + clubID;
// Redirect to the club page
window.location.href = url;
}

View File

@@ -0,0 +1,17 @@
const express = require('express');
const app = express();
// generate-league-routes.js
// Define a function to generate league routes
module.exports = function generateLeagueRoutes(app) {
// Define a route to handle requests to "/league/:leagueName"
app.get('/league/:leagueID', (req, res) => {
// Extract the league name from the URL parameters
const leagueID = req.params.leagueID;
// Render the league page template using Handlebars
res.render('pages/leagues-page', { leagueID: leagueID, user: user});
});
};

View File

@@ -0,0 +1,21 @@
const axios = require('axios');
const fetchTeamNames = async (selectedLeague) => {
try {
const response = await axios({
url: `http://api.football-data.org/v4/competitions/${selectedLeague}/teams`,
method: 'GET',
headers: {
'X-Auth-Token': '0aa1ed31245d4a36b1ef5a79150324b3',
},
});
const teams = response.data.teams.map(team => team.name);
return teams;
} catch (error) {
console.error('Error fetching teams data:', error);
return [];
}
};
module.exports = fetchTeamNames;

View File

@@ -0,0 +1,7 @@
function redirectToLeaguePage(leagueID) {
// Append the league name to the URL
var url = "/league/" + leagueID;
// Redirect to the league page
window.location.href = url;
}