Add page for adding sports

main
sudoer777 2021-11-22 18:47:40 -07:00
parent 31575212ad
commit f95015095d
3 changed files with 32 additions and 1 deletions

View File

@ -85,7 +85,7 @@ CATEGORIES.push(new Category(
row.appendChild(spacerCell);
},
async function addSport() {
//
window.location.href = "manage/addsport";
},
async function editSport() {

View File

@ -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;

View File

@ -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")