Add page to add teams

main
sudoer777 2021-11-22 19:17:23 -07:00
parent 1a3b013a0f
commit aacff9cca1
4 changed files with 57 additions and 3 deletions

View File

@ -178,10 +178,10 @@ CATEGORIES.push(new Category(
.then(data => sportCell.textContent = data); .then(data => sportCell.textContent = data);
row.appendChild(sportCell); row.appendChild(sportCell);
}, },
async function addSeason() { async function addTeam() {
// window.location.href = "manage/addteam";
}, },
async function editSeason() { async function editTeam() {
} }
)); ));

View File

@ -0,0 +1,18 @@
import * as Data from "../data.js";
const sportDropdown = document.getElementById('sport-dropdown');
async function listSports() {
sportDropdown.innerHTML = "";
const sportsList = await Data.getSports();
sportsList.forEach(sport => {
const option = document.createElement('option');
option.text = sport.name;
option.value = sport.id;
sportDropdown.appendChild(option);
});
}
listSports();

View File

@ -6,6 +6,7 @@ var seasons = require('../database/scores/seasons');
var sports = require('../database/scores/sports'); var sports = require('../database/scores/sports');
var divisions = require('../database/scores/divisions'); var divisions = require('../database/scores/divisions');
var genders = require('../database/scores/genders'); var genders = require('../database/scores/genders');
var teams = require('../database/scores/teams');
router.get('/', function(req, res, next) { router.get('/', function(req, res, next) {
@ -74,4 +75,16 @@ router.post('/submitdivision', function(req, res, next) {
} }
}); });
router.get('/addteam', function(req, res, next) {
res.render('manage/addteam', { title: 'Add team' });
});
router.post('/submitteam', function(req, res, next) {
const name = req.body['name'];
const sport = req.body['sport'];
teams.add(name, sport)
.then(res.send("SUCCESS"));
});
module.exports = router; module.exports = router;

View File

@ -0,0 +1,23 @@
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 Team
form(action='./submitteam', method='POST')
span(class='form-section')
label Sport
span(class='form-section-input')
select#sport-dropdown(name="sport" class="form-main-dropdown")
span(class='form-section')
label Team 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/manage/team.js' type="module")