Formatting changes + yesterday dynamically updates for scoreboard date parameter. Hover effect also added to focused game card
This commit is contained in:
@@ -6,6 +6,12 @@
|
||||
min-height: 100px;
|
||||
min-width: 200px;
|
||||
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 {
|
||||
|
||||
@@ -3,32 +3,45 @@ const axios = require('axios');
|
||||
|
||||
// Middleware function to fetch matches data
|
||||
const fetchMatchesData = async (req, res, next) => {
|
||||
try {
|
||||
try
|
||||
{
|
||||
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({
|
||||
url: 'http://api.football-data.org/v4/competitions/2021/matches',
|
||||
method: 'GET',
|
||||
params: {
|
||||
dateFrom: '2024-04-03', // Set dateFrom to today's date
|
||||
params:
|
||||
{
|
||||
dateFrom: yesterday, // Set dateFrom to today's date
|
||||
dateTo: today, // Set dateTo to today's date
|
||||
},
|
||||
headers: {
|
||||
headers:
|
||||
{
|
||||
'X-Auth-Token': '0aa1ed31245d4a36b1ef5a79150324b3', // Add your API key here
|
||||
},
|
||||
});
|
||||
|
||||
// Extract relevant data from the API response
|
||||
const matches = response.data.matches.map(match => ({
|
||||
homeTeam: {
|
||||
homeTeam:
|
||||
{
|
||||
name: match.homeTeam.name,
|
||||
crest: match.homeTeam.crest,
|
||||
},
|
||||
awayTeam: {
|
||||
awayTeam:
|
||||
{
|
||||
name: match.awayTeam.name,
|
||||
crest: match.awayTeam.crest,
|
||||
},
|
||||
score: {
|
||||
score:
|
||||
{
|
||||
homeScore: match.score.fullTime.home,
|
||||
awayScore: match.score.fullTime.away,
|
||||
},
|
||||
@@ -38,7 +51,10 @@ const fetchMatchesData = async (req, res, next) => {
|
||||
// Attach matches data to res.locals
|
||||
res.locals.matches = matches;
|
||||
next();
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
catch (error)
|
||||
{
|
||||
console.error('Error fetching Premier League matches:', error);
|
||||
res.locals.matches = []; // Set an empty array if there's an error
|
||||
next(); // Call next middleware or route handler
|
||||
|
||||
Reference in New Issue
Block a user