Add conver-time function to change time formatting and appearance. For exaple "FINISHED" now appears as "FT"
This commit is contained in:
@@ -85,6 +85,10 @@ app.use(express.static(path.join(__dirname, 'resources')));
|
||||
const fetchMatchesData = require('./resources/js/scoreboard-header/current-match-routes');
|
||||
app.use(fetchMatchesData);
|
||||
|
||||
const convert_time = require('./resources/js/scoreboard-header/convert-time');
|
||||
app.use(convert_time);
|
||||
|
||||
|
||||
/************************
|
||||
Login Page Routes
|
||||
*************************/
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Convert finished matches to "FT"
|
||||
const convert_time = (req, res, next) => {
|
||||
try {
|
||||
// Access matches data from res.locals
|
||||
const matches = res.locals.matches;
|
||||
|
||||
// Loop through matches and convert "FINISHED" to "FT" for minute
|
||||
const convertedMatches = matches.map(match => {
|
||||
if (match.minute === "FINISHED") {
|
||||
match.minute = "FT";
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// Update res.locals with converted matches
|
||||
res.locals.matches = convertedMatches;
|
||||
|
||||
// Proceed to the next middleware/route handler
|
||||
next();
|
||||
} catch (error) {
|
||||
// If an error occurs, log it and proceed to the next middleware/route handler
|
||||
console.error('Error converting finished matches:', error);
|
||||
next();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = convert_time;
|
||||
Reference in New Issue
Block a user