Add better loading for editing teams
parent
29605613c0
commit
8d830735ff
|
@ -14,14 +14,18 @@ async function initializeForm() {
|
|||
let params = new URLSearchParams(location.search);
|
||||
let teamID = params.get('team');
|
||||
if(teamID) {
|
||||
const team = await Data.getTeam(teamID);
|
||||
const team = await (await fetch(`/fetch/manage/team?team=${teamID}`)).json();
|
||||
|
||||
nameTextbox.value = team.name;
|
||||
|
||||
deleteButton.style.visibility = "visible";
|
||||
deleteButton.disabled = false;
|
||||
|
||||
Form.populateSports(sportDropdown, team.sportID);
|
||||
let data = {};
|
||||
data.sports = [team.sport];
|
||||
data.latestGame = {sportID : team.sportID };
|
||||
|
||||
Form.populateSports(sportDropdown, null, data);
|
||||
|
||||
Form.addHiddenValue('team', teamID, submissionForm);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ router.get('/team', async function(req, res, next) {
|
|||
console.error("ERROR: " + err.message);
|
||||
res.status(500).send("An error has occurred");
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
router.get('/games', async function(req, res, next) {
|
||||
try {
|
||||
|
|
|
@ -158,6 +158,18 @@ router.get('/manage/teams', async function (req, res, next) {
|
|||
res.json(data);
|
||||
});
|
||||
|
||||
router.get('/manage/team', async function (req, res, next) {
|
||||
try {
|
||||
const teamID = req.query.team;
|
||||
const data = await teams.getFromID(teamID);
|
||||
data.sport = await sports.getFromID(data.sportID);
|
||||
res.json(data);
|
||||
} catch(err) {
|
||||
console.error("ERROR: " + err.message);
|
||||
res.status(500).send("An error has occurred");
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/manage/games', checkLoginStatus.user, async function (req, res, next) {
|
||||
try{
|
||||
const userIsAdmin = req.user[2];
|
||||
|
|
Reference in New Issue