diff options
author | Julien Dessaux | 2022-11-22 22:55:36 +0100 |
---|---|---|
committer | Julien Dessaux | 2022-11-22 22:55:36 +0100 |
commit | 038c877aed55cffdb4401a4c7e7b15b113798145 (patch) | |
tree | e2902779e76ba8bd60b63be0e512a3c112530d68 /views/games.ejs | |
parent | Added basic games handling (diff) | |
download | jeux-de-mots-038c877aed55cffdb4401a4c7e7b15b113798145.tar.gz jeux-de-mots-038c877aed55cffdb4401a4c7e7b15b113798145.tar.bz2 jeux-de-mots-038c877aed55cffdb4401a4c7e7b15b113798145.zip |
Implemented game creation
Diffstat (limited to 'views/games.ejs')
-rw-r--r-- | views/games.ejs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/views/games.ejs b/views/games.ejs index 3189be8..9cee7bb 100644 --- a/views/games.ejs +++ b/views/games.ejs @@ -7,11 +7,31 @@ <tr><th>Partie</th><th>Joueur 1</th><th>Joueur 2</th></tr> <% games.forEach((game) => { %> <tr> - <td><a href="/games/<%= game.id %>"><%= game.data.title %></a></td> - <td><a href="/users/<%= game.player1 %>"><%= game.data.player1.name %></a></td> - <td><a href="/users/<%= game.player2 %>"><%= game.data.player2.name %></a></td> + <td><a href="/games/<%= game.id %>"><%= game.data.name %></a></td> + <td><a href="/users/<%= game.player1.id %>"><%= game.data.player1.username %></a></td> + <td><a href="/users/<%= game.player2.id %>"><%= game.data.player2.username %></a></td> </tr> <% }) %> </table> <% } %> +<% if (Object.keys(errors).length === 0) { %> +<h2>Nouvelle partie</h2> +<% } else { %> +<h2>Oops, erreur lors de la création d'une nouvelle partie!</h2> +<% } %> +<form action="/games" method="post"> + <div class="form-field<%= errors.username ? ' form-field-invalid' : '' %>"> + <input type="text" placeholder="Identifiant de votre adversaire" name="username" value="<%= formdata.username %>" required autofocus> + <% if (errors.username) { %> + <label class="error" for="username"><%= errors.username.msg %></label> + <% } %> + </div> + <div class="form-field<%= errors.name ? ' form-field-invalid' : '' %>"> + <input type="text" placeholder="Nom ou titre de cette partie" name="name" value="<%= formdata.name %>" required> + <% if (errors.name) { %> + <label class="error" for="name"><%= errors.name.msg %></label> + <% } %> + </div> + <button type="submit">Démarrer</button> +</form> <%- include("footer") %> |