diff --git a/routes/auth.js b/routes/auth.js index 539813b..c458cbc 100644 --- a/routes/auth.js +++ b/routes/auth.js @@ -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('/'); diff --git a/routes/posts.js b/routes/posts.js index e9789bc..d3d6564 100644 --- a/routes/posts.js +++ b/routes/posts.js @@ -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; \ No newline at end of file diff --git a/views/adminPage.ejs b/views/adminPage.ejs index 2ad0bac..cba6ec5 100644 --- a/views/adminPage.ejs +++ b/views/adminPage.ejs @@ -67,36 +67,62 @@
  • Les postes

    <% postData.forEach(post => { %> - <% if (post.isFinish) {%> -
    -

    <%= post.titre %>

    -

    - <%= post.commentairePost %> -

    -

    - Récompense : <%= post.recompense %> -

    -

    - statue : Accepté -

    -
    - <% } else {%> -
    -

    <%= post.titre %>

    -

    - Déscription : <%= post.commentaire %> -

    -

    - Récompense : <%= post.recompense %> -

    -

    - statue : en attente -

    - -
    - <% } %> + <% if (post.isFinish) {%> +
    +

    <%= post.titre %>

    +

    + <%= post.commentairePost %> +

    +

    + Récompense : <%= post.recompense %> +

    +

    + statue : Accepté +

    +
    + <% } else {%> +
    +

    <%= post.titre %>

    +

    + Déscription : <%= post.commentaire %> +

    +

    + Récompense : <%= post.recompense %> +

    +

    + statue : en attente +

    +
    +
    + + +
    + +
    +
    + <% } %> + <% resData.forEach(res => {%> + <% if (res.postId === post._id.toString()) { %> + <% console.log(res.postId) + console.log(post._id) + %> +
    +

    + <%= res.nom %> <%= res.prenom %> +

    +

    + <%= res.description %> +

    + image de la resolution +
    + <% } %> + <% }) %> <% }); %>