From e3c9205b00e476a7265e9820db37f9d0a509ed57 Mon Sep 17 00:00:00 2001 From: clement callaert Date: Wed, 1 Nov 2023 21:03:07 +0100 Subject: [PATCH] hotline modified --- data/database.js | 2 +- routes/posts.js | 22 ++++++++++++++++++++++ views/adminPage.ejs | 10 +++++++--- views/hotLine.ejs | 29 ++++++++++++++++++++++++++++- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/data/database.js b/data/database.js index 4570ff2..15a1408 100644 --- a/data/database.js +++ b/data/database.js @@ -6,7 +6,7 @@ let database; async function connectToDatabase() { const client = await MongoClient.connect('mongodb://127.0.0.1:27017') - database = client.db('BDS'); + database = client.db('BDE'); } function getDb() { diff --git a/routes/posts.js b/routes/posts.js index a5c6fa7..3bf8613 100644 --- a/routes/posts.js +++ b/routes/posts.js @@ -6,16 +6,20 @@ const db = require('../data/database'); const router = express.Router(); + router.post('/creerPost', async function (req,res) { const postData = req.body; const enteredTitre = postData.titre; const enteredCommentaire = postData.commentairePost; + const enterdRecompense = postData.recompense; const post ={ titre: enteredTitre, commentaire: enteredCommentaire, + recompense: enterdRecompense, isFinish: false, } await db.getDb().collection('posts').insertOne(post); + return res.redirect('/admin'); }) router.get('/hotLine', async function (req,res) { @@ -40,4 +44,22 @@ router.post('/commandeCrepe', async function (req, res) { res.redirect("/hotLine"); }) +router.post('/submitResolution/:postId', async function (req, res) { + const postId = req.params.postId; + const resolutionData = req.body; + const enteredDescription = resolutionData.description; + const user = req.session.user; + const nom = user.nom; + const prenom = user.prenom; + + const resolution = { + description: enteredDescription, + nom: nom, + prenom: prenom, + + } + + return res.redirect('/hotLine'); +}); + module.exports = router; \ No newline at end of file diff --git a/views/adminPage.ejs b/views/adminPage.ejs index 071636f..bda3645 100644 --- a/views/adminPage.ejs +++ b/views/adminPage.ejs @@ -40,7 +40,7 @@ <% }); %> @@ -48,15 +48,19 @@

Créer un poste pour la hotLine

-
+
- +
+
+ + +
diff --git a/views/hotLine.ejs b/views/hotLine.ejs index 6940015..a5b5971 100644 --- a/views/hotLine.ejs +++ b/views/hotLine.ejs @@ -1,5 +1,6 @@ <%- include('includes/head.ejs', {Title: 'Campagne BDE'}) %> + <%- include('includes/header') %> @@ -7,6 +8,17 @@ +
+

+ soumettre sa résolution +

+

+ test +

+
+ +
+

@@ -52,13 +64,28 @@

<%= post.commentairePost %>

+

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

+

+ statue : Accepté +

<% } else {%>

<%= post.titre %>

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

+

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

+

+ statue : en attente +

+
<% } %> <% }); %>