diff --git a/routes/submit.js b/routes/submit.js index 30901be..e79ff92 100644 --- a/routes/submit.js +++ b/routes/submit.js @@ -1,38 +1,31 @@ var express = require('express'); -var mail = require('../mail/mail'); var router = express.Router(); +var database = require('../database/database'); /* GET submit page. */ 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. */ router.post('/', function(req, res, next) { - 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']; + const year = req.body['year']; + const sport = req.body['sport']; + const gender = req.body['gender']; + const division = req.body['division']; + const date = req.body['date']; + const team1 = req.body['team1']; + const team1Score = req.body['team1-score']; + const team2 = req.body['team2']; + 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 " + submitter + "

" + - "Sport:
" + sport + " - " + gender + " - " + division + "

" + - "Home team:
" + home + " - " + homeScore + "

" + - "Visiting team:
" + visiting + " - " + visitingScore + "

"); -}; - - module.exports = router;