Remove mail functions for submit page

main
sudoer777 2021-11-20 16:51:08 -07:00
parent 93521dc431
commit 8213729009
1 changed files with 17 additions and 24 deletions

View File

@ -1,38 +1,31 @@
var express = require('express'); var express = require('express');
var mail = require('../mail/mail');
var router = express.Router(); var router = express.Router();
var database = require('../database/database');
/* GET submit page. */ /* GET submit page. */
router.get('/', function(req, res, next) { router.get('/', function(req, res, next) {
res.send('Nothing to send'); const date_ob = new Date();
const date = ("0" + date_ob.getDate()).slice(-2);
const month = ("0" + (date_ob.getMonth() + 1)).slice(-2);
const year = date_ob.getFullYear();
const currentDate = year + '-' + month + '-' + date;
res.render('submit', { title: 'Submit Score', date: currentDate });
}); });
/* POST submit page. */ /* POST submit page. */
router.post('/', function(req, res, next) { router.post('/', function(req, res, next) {
let sport = req.body.sport; const year = req.body['year'];
let gender = req.body.gender; const sport = req.body['sport'];
let division = req.body.division; const gender = req.body['gender'];
let home = req.body['home-team']; const division = req.body['division'];
let homeScore = req.body['home-team-score']; const date = req.body['date'];
let visiting = req.body['visiting-team']; const team1 = req.body['team1'];
let visitingScore = req.body['visiting-team-score']; const team1Score = req.body['team1-score'];
let submitter = req.body['submitter']; const team2 = req.body['team2'];
let recipient = req.body['email']; const team2Score = req.body['team2-score'];
let message = prepMailBody(sport, gender, division, home, homeScore, visiting, visitingScore, submitter);
mail.send(recipient, "Score Report", message);
res.send('Score sent');
}); });
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>");
};
module.exports = router; module.exports = router;