diff --git a/public/scripts/manage.js b/public/scripts/manage.js index 2f24fc4..2017341 100644 --- a/public/scripts/manage.js +++ b/public/scripts/manage.js @@ -85,7 +85,7 @@ CATEGORIES.push(new Category( row.appendChild(spacerCell); }, async function addSport() { - // + window.location.href = "manage/addsport"; }, async function editSport() { diff --git a/routes/manage.js b/routes/manage.js index 72d0784..4582727 100644 --- a/routes/manage.js +++ b/routes/manage.js @@ -3,6 +3,7 @@ var router = express.Router(); var genders = require('../database/scores/genders'); var games = require('../database/scores/games'); var seasons = require('../database/scores/seasons'); +var sports = require('../database/scores/sports'); router.get('/', function(req, res, next) { @@ -39,4 +40,15 @@ router.post('/submitseason', function(req, res, next) { .then(res.send("SUCCESS")); }); +router.get('/addsport', function(req, res, next) { + res.render('manage/addsport', { title: 'Add sport' }); +}); + +router.post('/submitsport', function(req, res, next) { + const name = req.body['name']; + + sports.add(name) + .then(res.send("SUCCESS")); +}); + module.exports = router; diff --git a/views/manage/addsport.pug b/views/manage/addsport.pug new file mode 100644 index 0000000..7f7e5ad --- /dev/null +++ b/views/manage/addsport.pug @@ -0,0 +1,19 @@ +extends layout + +block stylesheets + link(rel='stylesheet', href='/stylesheets/submit.css') + link(rel='stylesheet', href='/stylesheets/form.css') + +block content + div#mobile-view + h1 Add Sport + form(action='./submitsport', method='POST') + span(class='form-section') + label Sport name + span(class='form-section-input') + input(type="text", name="name") + span(class='form-section') + button#submit-button(type="submit") Submit + +block scripts + script(src='/scripts/sport.js' type="module") \ No newline at end of file