League data imported to league page
This commit is contained in:
@@ -94,10 +94,14 @@ const fetchLeaguesData = require('./resources/routes/league-pages/get-current-le
|
||||
|
||||
// Define the route for fetching league data
|
||||
app.get('/league/:leagueID', fetchLeaguesData, (req, res) => {
|
||||
// Handle the response here
|
||||
res.json(res.locals.leagues);
|
||||
// Render the Handlebars view with league data
|
||||
res.render('pages/league-page', {
|
||||
leagueID: req.params.leagueID,
|
||||
leagues: res.locals.leagues
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// *****************************************************
|
||||
// <!-- Section 5 : API Routes -->
|
||||
// *****************************************************
|
||||
|
||||
@@ -1,40 +1,36 @@
|
||||
<!-- league-page.hbs -->
|
||||
<!-- pages/league.hbs -->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ league_name }}</title>
|
||||
<title>League Information</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ leagueID }}</h1>
|
||||
<h1>{{ league_name }}</h1>
|
||||
|
||||
<!-- Display league emblem -->
|
||||
{{#if leagueEmblem}}
|
||||
<img src="{{ leagueEmblem }}" alt="{{ leagueName }} Emblem">
|
||||
{{/if}}
|
||||
|
||||
<!-- Display league standings -->
|
||||
<h2>Standings</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Position</th>
|
||||
<th>Team</th>
|
||||
<th>Crest</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#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>
|
||||
<h1>League Information</h1>
|
||||
<p>League ID: {{leagueID}}</p>
|
||||
{{#if leagues}}
|
||||
<ul>
|
||||
{{#each leagues}}
|
||||
<li>
|
||||
<h2>{{competition.league_name}}</h2>
|
||||
<img src="{{competition.league_emblem}}" alt="{{competition.league_name}} Emblem">
|
||||
<h3>Standings</h3>
|
||||
<ol>
|
||||
{{#each standings}}
|
||||
<li>
|
||||
<span>Position: {{table.league_position}}</span>
|
||||
<span>Team Name: {{table.team_name}}</span>
|
||||
<img src="{{table.team_crest}}" alt="{{table.team_name}} Crest">
|
||||
</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</li>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</ul>
|
||||
{{else}}
|
||||
<p>No league data available</p>
|
||||
{{/if}}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user