update admin-page
This commit is contained in:
parent
5b289819d7
commit
033e537bf0
3 changed files with 65 additions and 31 deletions
|
@ -146,7 +146,7 @@ router.post('/connexion', async function (req, res) {
|
|||
})
|
||||
return;
|
||||
}
|
||||
req.session.user = { id: existingUser._id, nom_dutilisateur: existingUser.nom_dutilisateur};
|
||||
req.session.user = { id: existingUser._id, nom_dutilisateur: existingUser.nom_dutilisateur, nom: existingUser.nom, prenom: existingUser.prenom, email: existingUser.email};
|
||||
req.session.isAuthenticated = true;
|
||||
req.session.save(function () {
|
||||
res.redirect('/');
|
||||
|
|
|
@ -85,4 +85,12 @@ router.post('/submitResolution/:postId', upload.single('image'), async function
|
|||
return res.redirect('/hotLine')
|
||||
})
|
||||
|
||||
router.post('/accepter/:id', async function (req, res) {
|
||||
const postId = req.params.id;
|
||||
const winner = req.body.utilisateur;
|
||||
await db.getDb().collection('post').updateOne({_id: postId}, {isFinish: true});
|
||||
await db.getDb().collection('res').updateOne({_id: postId}, {winner: winner});
|
||||
res.redirect('/admin')
|
||||
})
|
||||
|
||||
module.exports = router;
|
|
@ -67,36 +67,62 @@
|
|||
<li>
|
||||
<h2>Les postes</h2>
|
||||
<% postData.forEach(post => { %>
|
||||
<% if (post.isFinish) {%>
|
||||
<div id="postFinish">
|
||||
<h2><%= post.titre %></h2>
|
||||
<p>
|
||||
<%= post.commentairePost %>
|
||||
</p>
|
||||
<p>
|
||||
Récompense : <%= post.recompense %>
|
||||
</p>
|
||||
<p>
|
||||
statue : Accepté
|
||||
</p>
|
||||
</div>
|
||||
<% } else {%>
|
||||
<div id="postNotFinish">
|
||||
<h2><%= post.titre %></h2>
|
||||
<p>
|
||||
Déscription : <%= post.commentaire %>
|
||||
</p>
|
||||
<p>
|
||||
Récompense : <%= post.recompense %>
|
||||
</p>
|
||||
<p>
|
||||
statue : en attente
|
||||
</p>
|
||||
<button id="but<%= post._id %>" data-post-id="<%= post._id %>">
|
||||
Soummettre sa resolution
|
||||
</button>
|
||||
</div>
|
||||
<% } %>
|
||||
<% if (post.isFinish) {%>
|
||||
<div id="postFinish">
|
||||
<h2><%= post.titre %></h2>
|
||||
<p>
|
||||
<%= post.commentairePost %>
|
||||
</p>
|
||||
<p>
|
||||
Récompense : <%= post.recompense %>
|
||||
</p>
|
||||
<p>
|
||||
statue : Accepté
|
||||
</p>
|
||||
</div>
|
||||
<% } else {%>
|
||||
<div id="postNotFinish">
|
||||
<h2><%= post.titre %></h2>
|
||||
<p>
|
||||
Déscription : <%= post.commentaire %>
|
||||
</p>
|
||||
<p>
|
||||
Récompense : <%= post.recompense %>
|
||||
</p>
|
||||
<p>
|
||||
statue : en attente
|
||||
</p>
|
||||
<form action="/accepter/<%= post._id %>" method="post">
|
||||
<div>
|
||||
<label for="utilisateur">Le gagnant est : </label>
|
||||
<select name="utilisateur" id="utilisateur">
|
||||
<% users.forEach(user => { %>
|
||||
<option value="<%= user.nom_dutilisateur %>"><%= user.nom_dutilisateur %></option>
|
||||
<% }); %>
|
||||
</select>
|
||||
</div>
|
||||
<button id="but<%= post._id %>">
|
||||
Accepter
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<% } %>
|
||||
<% resData.forEach(res => {%>
|
||||
<% if (res.postId === post._id.toString()) { %>
|
||||
<% console.log(res.postId)
|
||||
console.log(post._id)
|
||||
%>
|
||||
<div>
|
||||
<h3>
|
||||
<%= res.nom %> <%= res.prenom %>
|
||||
</h3>
|
||||
<p>
|
||||
<%= res.description %>
|
||||
</p>
|
||||
<img src="<%= res.imagePath %>" alt="image de la resolution">
|
||||
</div>
|
||||
<% } %>
|
||||
<% }) %>
|
||||
<% }); %>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue