This commit is contained in:
2026-02-02 19:12:40 +01:00
parent c6421049c8
commit 952c353118
17 changed files with 982 additions and 513 deletions

View File

@@ -164,7 +164,8 @@ function registerAdminRoutes(app) {
return res.json({
config: {
saturday_percentage: 100,
sunday_percentage: 100
sunday_percentage: 100,
checkin_root_url: null
}
});
}
@@ -174,7 +175,7 @@ function registerAdminRoutes(app) {
// Optionen speichern
app.post('/admin/options', requireAdmin, (req, res) => {
const { saturday_percentage, sunday_percentage } = req.body;
const { saturday_percentage, sunday_percentage, checkin_root_url } = req.body;
// Validierung
const satPercent = parseFloat(saturday_percentage);
@@ -188,6 +189,12 @@ function registerAdminRoutes(app) {
return res.status(400).json({ error: 'Prozentsätze müssen zwischen 100 und 200 liegen' });
}
// Validierung der Root URL (optional, kann leer sein)
let rootUrl = checkin_root_url ? checkin_root_url.trim() : null;
if (rootUrl === '') {
rootUrl = null;
}
// Prüfe ob Eintrag existiert
db.get('SELECT id FROM system_options WHERE id = 1', (err, existing) => {
if (err) {
@@ -196,8 +203,8 @@ function registerAdminRoutes(app) {
if (existing) {
// Update
db.run('UPDATE system_options SET saturday_percentage = ?, sunday_percentage = ?, updated_at = CURRENT_TIMESTAMP WHERE id = 1',
[satPercent, sunPercent],
db.run('UPDATE system_options SET saturday_percentage = ?, sunday_percentage = ?, checkin_root_url = ?, updated_at = CURRENT_TIMESTAMP WHERE id = 1',
[satPercent, sunPercent, rootUrl],
(err) => {
if (err) {
return res.status(500).json({ error: 'Fehler beim Speichern der Optionen' });
@@ -206,8 +213,8 @@ function registerAdminRoutes(app) {
});
} else {
// Insert
db.run('INSERT INTO system_options (id, saturday_percentage, sunday_percentage) VALUES (1, ?, ?)',
[satPercent, sunPercent],
db.run('INSERT INTO system_options (id, saturday_percentage, sunday_percentage, checkin_root_url) VALUES (1, ?, ?, ?)',
[satPercent, sunPercent, rootUrl],
(err) => {
if (err) {
return res.status(500).json({ error: 'Fehler beim Speichern der Optionen' });