This repository has been archived on 2024-04-05. You can view files and clone it, but cannot push or open issues/pull-requests.
score-tracker/routes/submit.js

28 lines
910 B
JavaScript
Raw Normal View History

2021-09-30 20:49:44 +00:00
var express = require('express');
var router = express.Router();
2021-11-22 00:43:34 +00:00
var genders = require('../database/scores/genders');
var games = require('../database/scores/games');
2021-09-30 20:49:44 +00:00
/* GET submit page. */
router.get('/', function(req, res, next) {
2021-11-22 04:41:53 +00:00
res.render('submit', { title: 'Submit Score' });
2021-09-30 20:55:01 +00:00
});
/* POST submit page. */
router.post('/', function(req, res, next) {
2021-11-22 00:43:34 +00:00
const seasonID = req.body['year'];
const sportID = req.body['sport'];
const gender = (req.body['gender'] == "female") ? genders.FEMALE : genders.MALE;
const divisionID = req.body['division'];
const date = moment(req.body['date']);
const team1ID = req.body['team1'];
2021-11-20 23:51:08 +00:00
const team1Score = req.body['team1-score'];
2021-11-22 00:43:34 +00:00
const team2ID = req.body['team2'];
2021-11-20 23:51:08 +00:00
const team2Score = req.body['team2-score'];
2021-10-04 03:50:55 +00:00
2021-11-22 00:43:34 +00:00
games.add(divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score)
.then(res.send("SUCCESS"));
2021-09-30 20:49:44 +00:00
});
module.exports = router;