Formatting changes + yesterday dynamically updates for scoreboard date parameter. Hover effect also added to focused game card

This commit is contained in:
2024-04-03 23:35:38 -06:00
parent 1a771845bd
commit 1d50359612
3 changed files with 30 additions and 8 deletions

View File

@@ -6,6 +6,12 @@
min-height: 100px; min-height: 100px;
min-width: 200px; min-width: 200px;
box-sizing: border-box; box-sizing: border-box;
transition: transform 0.4s ease; /* Add transition for smooth effect */
}
#game-card:hover {
transform: scale(1.05); /* Scale up by 10% on hover */
} }
.score-card-body { .score-card-body {

View File

@@ -3,32 +3,45 @@ const axios = require('axios');
// Middleware function to fetch matches data // Middleware function to fetch matches data
const fetchMatchesData = async (req, res, next) => { const fetchMatchesData = async (req, res, next) => {
try { try
{
const today = moment().format('YYYY-MM-DD'); // Get today's date in YYYY-MM-DD format const today = moment().format('YYYY-MM-DD'); // Get today's date in YYYY-MM-DD format
// Subtract one day to get yesterday's date
var yesterdayUnformatted = moment().subtract(1, 'days');
// Format yesterday's date as YYYY-MM-DD
var yesterday = yesterdayUnformatted.format('YYYY-MM-DD');
const response = await axios({ const response = await axios({
url: 'http://api.football-data.org/v4/competitions/2021/matches', url: 'http://api.football-data.org/v4/competitions/2021/matches',
method: 'GET', method: 'GET',
params: { params:
dateFrom: '2024-04-03', // Set dateFrom to today's date {
dateFrom: yesterday, // Set dateFrom to today's date
dateTo: today, // Set dateTo to today's date dateTo: today, // Set dateTo to today's date
}, },
headers: { headers:
{
'X-Auth-Token': '0aa1ed31245d4a36b1ef5a79150324b3', // Add your API key here 'X-Auth-Token': '0aa1ed31245d4a36b1ef5a79150324b3', // Add your API key here
}, },
}); });
// Extract relevant data from the API response // Extract relevant data from the API response
const matches = response.data.matches.map(match => ({ const matches = response.data.matches.map(match => ({
homeTeam: { homeTeam:
{
name: match.homeTeam.name, name: match.homeTeam.name,
crest: match.homeTeam.crest, crest: match.homeTeam.crest,
}, },
awayTeam: { awayTeam:
{
name: match.awayTeam.name, name: match.awayTeam.name,
crest: match.awayTeam.crest, crest: match.awayTeam.crest,
}, },
score: { score:
{
homeScore: match.score.fullTime.home, homeScore: match.score.fullTime.home,
awayScore: match.score.fullTime.away, awayScore: match.score.fullTime.away,
}, },
@@ -38,7 +51,10 @@ const fetchMatchesData = async (req, res, next) => {
// Attach matches data to res.locals // Attach matches data to res.locals
res.locals.matches = matches; res.locals.matches = matches;
next(); next();
} catch (error) { }
catch (error)
{
console.error('Error fetching Premier League matches:', error); console.error('Error fetching Premier League matches:', error);
res.locals.matches = []; // Set an empty array if there's an error res.locals.matches = []; // Set an empty array if there's an error
next(); // Call next middleware or route handler next(); // Call next middleware or route handler