League data imported to league page

This commit is contained in:
Lucas Patenaude
2024-04-13 15:19:16 -06:00
parent f142b8e285
commit 5644bd1b28
2 changed files with 31 additions and 31 deletions

View File

@@ -94,10 +94,14 @@ const fetchLeaguesData = require('./resources/routes/league-pages/get-current-le
// Define the route for fetching league data // Define the route for fetching league data
app.get('/league/:leagueID', fetchLeaguesData, (req, res) => { app.get('/league/:leagueID', fetchLeaguesData, (req, res) => {
// Handle the response here // Render the Handlebars view with league data
res.json(res.locals.leagues); res.render('pages/league-page', {
leagueID: req.params.leagueID,
leagues: res.locals.leagues
});
}); });
// ***************************************************** // *****************************************************
// <!-- Section 5 : API Routes --> // <!-- Section 5 : API Routes -->
// ***************************************************** // *****************************************************

View File

@@ -1,40 +1,36 @@
<!-- league-page.hbs --> <!-- pages/league.hbs -->
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ league_name }}</title> <title>League Information</title>
</head> </head>
<body> <body>
<h1>{{ leagueID }}</h1> <h1>League Information</h1>
<h1>{{ league_name }}</h1> <p>League ID: {{leagueID}}</p>
{{#if leagues}}
<!-- Display league emblem --> <ul>
{{#if leagueEmblem}} {{#each leagues}}
<img src="{{ leagueEmblem }}" alt="{{ leagueName }} Emblem"> <li>
{{/if}} <h2>{{competition.league_name}}</h2>
<img src="{{competition.league_emblem}}" alt="{{competition.league_name}} Emblem">
<!-- Display league standings --> <h3>Standings</h3>
<h2>Standings</h2> <ol>
<table> {{#each standings}}
<thead> <li>
<tr> <span>Position: {{table.league_position}}</span>
<th>Position</th> <span>Team Name: {{table.team_name}}</span>
<th>Team</th> <img src="{{table.team_crest}}" alt="{{table.team_name}} Crest">
<th>Crest</th> </li>
</tr> {{/each}}
</thead> </ol>
<tbody> </li>
{{#each standings}}
<tr>
<td>{{ this.league_position }}</td>
<td>{{ this.team_name }}</td>
<td><img src="{{ this.team_crest }}" alt="{{ this.team_name }} Crest"></td>
</tr>
{{/each}} {{/each}}
</tbody> </ul>
</table> {{else}}
<p>No league data available</p>
{{/if}}
</body> </body>
</html> </html>