Spieletyp hinzugefügt
This commit is contained in:
		
							parent
							
								
									0795cab7e5
								
							
						
					
					
						commit
						7a6076cd46
					
				
							
								
								
									
										7
									
								
								app.js
								
								
								
								
							
							
						
						
									
										7
									
								
								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
 | // Gerenderte Seite für gewähltes Spiel
 | ||||||
| app.get('/spiel/:id', async (req, res) => { | app.get('/spiel/:id', async (req, res) => { | ||||||
|   const { id } = req.params; |   const { id } = req.params; | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ | ||||||
|     <h2>Variationen</h2> |     <h2>Variationen</h2> | ||||||
|     <p><%- spiel.variationen %></p> |     <p><%- spiel.variationen %></p> | ||||||
|         <% if (session && (session.role === 'user' || session.role==='admin')) {%> |         <% if (session && (session.role === 'user' || session.role==='admin')) {%> | ||||||
|     <button class="btn btn-primary" onclick="toggleDivs()">Zum Edit-Modus wechseln</button> |     <button class="btn btn-primary" onclick="toggleDivs()">Bearbeiten</button> | ||||||
| 
 | 
 | ||||||
| </div> | </div> | ||||||
| 
 | 
 | ||||||
|  | @ -42,9 +42,14 @@ | ||||||
|         </select><%= spiel.dauer %><br> |         </select><%= spiel.dauer %><br> | ||||||
|         <strong>Regeln: </strong><br><textarea name="regeln"><%- spiel.regeln %> </textarea><br> |         <strong>Regeln: </strong><br><textarea name="regeln"><%- spiel.regeln %> </textarea><br> | ||||||
|         <strong>Variationen: </strong><br><textarea name="variationen"><%- spiel.variationen %> </textarea><br> |         <strong>Variationen: </strong><br><textarea name="variationen"><%- spiel.variationen %> </textarea><br> | ||||||
|         <button type="submit">Speichern</button> |         <button type="submit" class="btn btn-success">Speichern</button> | ||||||
|     </form> |     </form> | ||||||
|     <button class="btn btn-secondary" onclick="toggleDivs()">Zum View-Modus wechseln</button> | 
 | ||||||
|  |     <form method="POST" action="/delete-spiel"> | ||||||
|  |         <input type="hidden" name="spielId" value="<%= spiel.id %>"> | ||||||
|  |         <button type="submit" class="btn btn-danger">Spiel löschen</button> | ||||||
|  |     </form> | ||||||
|  |     <button class="btn btn-secondary" onclick="toggleDivs()">Abbrechen</button> | ||||||
| </div> | </div> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue