From 7a6076cd467a8fa7239652dc9dbb7d902b264beb Mon Sep 17 00:00:00 2001 From: Klaas Date: Thu, 30 May 2024 18:29:14 +0200 Subject: [PATCH] =?UTF-8?q?Spieletyp=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 7 +++++++ views/spiel.ejs | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index c028189..f17023e 100644 --- a/app.js +++ b/app.js @@ -663,6 +663,13 @@ app.get('/spiele', async (req, res) => { } }) +app.post('/delete-spiel', requireAdmin ,async (req, res) => { + const { spielId } = req.body; + console.log(spielId); + await pool.query('DELETE FROM spiele WHERE id = $1', [spielId]); + res.redirect('/spiele'); +}) + // Gerenderte Seite für gewähltes Spiel app.get('/spiel/:id', async (req, res) => { const { id } = req.params; diff --git a/views/spiel.ejs b/views/spiel.ejs index ded82b4..8ec81fc 100644 --- a/views/spiel.ejs +++ b/views/spiel.ejs @@ -26,7 +26,7 @@

Variationen

<%- spiel.variationen %>

<% if (session && (session.role === 'user' || session.role==='admin')) {%> - + @@ -42,9 +42,14 @@ <%= spiel.dauer %>
Regeln:

Variationen:

- + - + +
+ + +
+