From 9f2572336fc897e758bc6cdff00902936e72f837 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Mon, 22 Nov 2021 17:48:51 -0700 Subject: [PATCH] Move game submit page from /submit to /manage/addgame --- public/scripts/manage.js | 17 +-------------- routes/manage.js | 23 +++++++++++++++++++- routes/submit.js | 27 ------------------------ views/{submit.pug => manage/addgame.pug} | 2 +- views/manage/layout.pug | 10 +++++++++ 5 files changed, 34 insertions(+), 45 deletions(-) delete mode 100644 routes/submit.js rename views/{submit.pug => manage/addgame.pug} (93%) create mode 100644 views/manage/layout.pug diff --git a/public/scripts/manage.js b/public/scripts/manage.js index 80bc534..04656eb 100644 --- a/public/scripts/manage.js +++ b/public/scripts/manage.js @@ -52,9 +52,6 @@ CATEGORIES.push(new Category( async function addSeason() { // }, - async function submitSeason() { - // - }, async function editSeason() { } @@ -89,9 +86,6 @@ CATEGORIES.push(new Category( async function addSport() { // }, - async function submitSport() { - // - }, async function editSport() { } @@ -143,9 +137,6 @@ CATEGORIES.push(new Category( async function addSeason() { // }, - async function submitSeason() { - // - }, async function editSeason() { } @@ -189,9 +180,6 @@ CATEGORIES.push(new Category( async function addSeason() { // }, - async function submitSeason() { - // - }, async function editSeason() { } @@ -278,10 +266,7 @@ CATEGORIES.push(new Category( dateCell.appendChild(dateSpan); row.appendChild(dateCell); }, - async function addSeason() { - // - }, - async function submitSeason() { + async function addGame() { // }, async function editSeason() { diff --git a/routes/manage.js b/routes/manage.js index 796064b..454c3c9 100644 --- a/routes/manage.js +++ b/routes/manage.js @@ -1,9 +1,30 @@ var express = require('express'); var router = express.Router(); +var genders = require('../database/scores/genders'); +var games = require('../database/scores/games'); + -/* GET manage page. */ router.get('/', function(req, res, next) { res.render('manage', { title: 'Score Management' }); }); +router.get('/addgame', function(req, res, next) { + res.render('manage/addgame', { title: 'Submit Score' }); +}); + +router.post('/submitgame', function(req, res, next) { + const seasonID = req.body['year']; + const sportID = req.body['sport']; + const gender = (req.body['gender'] == "female") ? genders.FEMALE : genders.MALE; + const divisionID = req.body['division']; + const date = req.body['date']; + const team1ID = req.body['team1']; + const team1Score = req.body['team1-score']; + const team2ID = req.body['team2']; + const team2Score = req.body['team2-score']; + + games.add(divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score) + .then(res.send("SUCCESS")); +}); + module.exports = router; diff --git a/routes/submit.js b/routes/submit.js deleted file mode 100644 index fcd660b..0000000 --- a/routes/submit.js +++ /dev/null @@ -1,27 +0,0 @@ -var express = require('express'); -var router = express.Router(); -var genders = require('../database/scores/genders'); -var games = require('../database/scores/games'); - -/* GET submit page. */ -router.get('/', function(req, res, next) { - res.render('submit', { title: 'Submit Score' }); -}); - -/* POST submit page. */ -router.post('/', function(req, res, next) { - const seasonID = req.body['year']; - const sportID = req.body['sport']; - const gender = (req.body['gender'] == "female") ? genders.FEMALE : genders.MALE; - const divisionID = req.body['division']; - const date = moment(req.body['date']); - const team1ID = req.body['team1']; - const team1Score = req.body['team1-score']; - const team2ID = req.body['team2']; - const team2Score = req.body['team2-score']; - - games.add(divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score) - .then(res.send("SUCCESS")); -}); - -module.exports = router; diff --git a/views/submit.pug b/views/manage/addgame.pug similarity index 93% rename from views/submit.pug rename to views/manage/addgame.pug index 85f352f..04026f4 100644 --- a/views/submit.pug +++ b/views/manage/addgame.pug @@ -7,7 +7,7 @@ block stylesheets block content div#mobile-view h1 Submit Score - form(action='/submit', method='POST') + form(action='./submitgame', method='POST') span(class='form-section') label Year span(class='form-section-input') diff --git a/views/manage/layout.pug b/views/manage/layout.pug new file mode 100644 index 0000000..e4f85eb --- /dev/null +++ b/views/manage/layout.pug @@ -0,0 +1,10 @@ +doctype html +html + head + title= title + meta(name='viewport', content='width=device-width, initial-scale=1') + link(rel='stylesheet', href='/stylesheets/style.css') + block stylesheets + body + block content + block scripts