2021-09-30 20:49:44 +00:00
|
|
|
var express = require('express');
|
2021-10-04 03:50:55 +00:00
|
|
|
var mail = require('../mail/mail');
|
2021-09-30 20:49:44 +00:00
|
|
|
var router = express.Router();
|
|
|
|
|
|
|
|
/* GET submit page. */
|
|
|
|
router.get('/', function(req, res, next) {
|
2021-09-30 20:55:01 +00:00
|
|
|
res.send('Nothing to send');
|
|
|
|
});
|
|
|
|
|
|
|
|
/* POST submit page. */
|
|
|
|
router.post('/', function(req, res, next) {
|
2021-10-04 03:50:55 +00:00
|
|
|
let sport = req.body.sport;
|
|
|
|
let gender = req.body.gender;
|
|
|
|
let division = req.body.division;
|
|
|
|
let home = req.body['home-team'];
|
|
|
|
let homeScore = req.body['home-team-score'];
|
|
|
|
let visiting = req.body['visiting-team'];
|
|
|
|
let visitingScore = req.body['visiting-team-score'];
|
|
|
|
let submitter = req.body['submitter'];
|
|
|
|
let recipient = req.body['email'];
|
|
|
|
|
|
|
|
let message = prepMailBody(sport, gender, division, home, homeScore, visiting, visitingScore, submitter);
|
|
|
|
|
|
|
|
mail.send(recipient, "Score Report", message);
|
|
|
|
|
2021-09-30 20:55:01 +00:00
|
|
|
res.send('Score sent');
|
2021-09-30 20:49:44 +00:00
|
|
|
});
|
|
|
|
|
2021-10-04 03:50:55 +00:00
|
|
|
var prepMailBody = function(sport, gender, division, home, homeScore, visiting, visitingScore, submitter) {
|
|
|
|
return(
|
|
|
|
"Score report from <b>" + submitter + "</b><br><br>" +
|
|
|
|
"<b>Sport:</b><br>" + sport + " - " + gender + " - " + division + "<br><br>" +
|
|
|
|
"<b>Home team:</b><br>" + home + " - " + homeScore + "<br><br>" +
|
|
|
|
"<b>Visiting team:</b><br>" + visiting + " - " + visitingScore + "<br><br>");
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-09-30 20:49:44 +00:00
|
|
|
module.exports = router;
|