From f95015095d425d28147d16c4ff52bdbea0144ab2 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Mon, 22 Nov 2021 18:47:40 -0700 Subject: [PATCH] Add page for adding sports --- public/scripts/manage.js | 2 +- routes/manage.js | 12 ++++++++++++ views/manage/addsport.pug | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 views/manage/addsport.pug 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