Direct user to specific section in manage page when leaving an edit page
parent
b9b4e25aec
commit
fcf9d28dd6
|
@ -50,11 +50,11 @@ router.post('/game', checkLoginStatus.user, async function(req, res, next) {
|
||||||
}
|
}
|
||||||
else if(remove) {
|
else if(remove) {
|
||||||
await games.remove(id);
|
await games.remove(id);
|
||||||
res.redirect("/manage");
|
res.redirect('/manage#games');
|
||||||
}
|
}
|
||||||
else if(id) {
|
else if(id) {
|
||||||
await games.edit(id, divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score);
|
await games.edit(id, divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score);
|
||||||
res.redirect('/manage');
|
res.redirect('/manage#games');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await games.add(divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score, userID);
|
await games.add(divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score, userID);
|
||||||
|
@ -81,7 +81,7 @@ router.post('/season', checkLoginStatus.admin, async function(req, res, next) {
|
||||||
if(remove) await seasons.remove(seasonID);
|
if(remove) await seasons.remove(seasonID);
|
||||||
else await seasons.add(year);
|
else await seasons.add(year);
|
||||||
|
|
||||||
res.redirect('/manage');
|
res.redirect('/manage#seasons');
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error("ERROR: " + err.message);
|
console.error("ERROR: " + err.message);
|
||||||
req.flash("error", "An error has occurred.");
|
req.flash("error", "An error has occurred.");
|
||||||
|
@ -106,7 +106,7 @@ router.post('/sport', checkLoginStatus.admin, async function(req, res, next) {
|
||||||
else if(id) await sports.rename(id, name);
|
else if(id) await sports.rename(id, name);
|
||||||
else await sports.add(name);
|
else await sports.add(name);
|
||||||
|
|
||||||
res.redirect('/manage');
|
res.redirect('/manage#sports');
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error("ERROR: " + err.message);
|
console.error("ERROR: " + err.message);
|
||||||
req.flash("error", "An error has occurred.");
|
req.flash("error", "An error has occurred.");
|
||||||
|
@ -140,7 +140,7 @@ router.post('/division', checkLoginStatus.admin, async function(req, res, next)
|
||||||
await divisions.add(name, gender, sport);
|
await divisions.add(name, gender, sport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res.redirect('/manage');
|
res.redirect('/manage#divisions');
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error("ERROR: " + err.message);
|
console.error("ERROR: " + err.message);
|
||||||
req.flash("error", "An error has occurred.");
|
req.flash("error", "An error has occurred.");
|
||||||
|
@ -162,9 +162,9 @@ router.post('/team', checkLoginStatus.admin, async function(req, res, next) {
|
||||||
const name = req.body['name'];
|
const name = req.body['name'];
|
||||||
const sport = req.body['sport'];
|
const sport = req.body['sport'];
|
||||||
|
|
||||||
if(remove) teams.remove(id).then(res.redirect('/manage'));
|
if(remove) teams.remove(id).then(res.redirect('/manage#teams'));
|
||||||
else if(id) teams.rename(id, name).then(res.redirect('/manage'));
|
else if(id) teams.rename(id, name).then(res.redirect('/manage#teams'));
|
||||||
else teams.add(name, sport).then(res.redirect("/manage"));
|
else teams.add(name, sport).then(res.redirect('/manage#teams'));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error("ERROR: " + err.message);
|
console.error("ERROR: " + err.message);
|
||||||
req.flash("error", "An error has occurred.");
|
req.flash("error", "An error has occurred.");
|
||||||
|
@ -209,7 +209,7 @@ router.post('/account', checkLoginStatus.user, async function(req, res, next) {
|
||||||
else if(accountID) await accounts.edit(accountID, email, password, isAdmin);
|
else if(accountID) await accounts.edit(accountID, email, password, isAdmin);
|
||||||
else await accounts.create(req.body.email, req.body.password, !!req.body.admin);
|
else await accounts.create(req.body.email, req.body.password, !!req.body.admin);
|
||||||
|
|
||||||
res.redirect('/manage');
|
res.redirect('/manage#accounts');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error("ERROR: " + err.message);
|
console.error("ERROR: " + err.message);
|
||||||
|
|
Reference in New Issue