Add page to add teams
parent
1a3b013a0f
commit
aacff9cca1
|
@ -178,10 +178,10 @@ CATEGORIES.push(new Category(
|
|||
.then(data => sportCell.textContent = data);
|
||||
row.appendChild(sportCell);
|
||||
},
|
||||
async function addSeason() {
|
||||
//
|
||||
async function addTeam() {
|
||||
window.location.href = "manage/addteam";
|
||||
},
|
||||
async function editSeason() {
|
||||
async function editTeam() {
|
||||
|
||||
}
|
||||
));
|
||||
|
|
|
@ -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();
|
|
@ -6,6 +6,7 @@ var seasons = require('../database/scores/seasons');
|
|||
var sports = require('../database/scores/sports');
|
||||
var divisions = require('../database/scores/divisions');
|
||||
var genders = require('../database/scores/genders');
|
||||
var teams = require('../database/scores/teams');
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -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")
|
Reference in New Issue