hotline modified
This commit is contained in:
parent
244d45ceb8
commit
e3c9205b00
4 changed files with 58 additions and 5 deletions
|
@ -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() {
|
||||
|
|
|
@ -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;
|
|
@ -40,7 +40,7 @@
|
|||
<% }); %>
|
||||
</select>
|
||||
<button>
|
||||
submit
|
||||
Submit
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
|
@ -48,15 +48,19 @@
|
|||
<h2>
|
||||
Créer un poste pour la hotLine
|
||||
</h2>
|
||||
<form action="/creerPost">
|
||||
<form action="/creerPost" method="post">
|
||||
<div>
|
||||
<label for="title">Titre du poste: </label>
|
||||
<input type="text" name="titre" id="titre">
|
||||
</div>
|
||||
<div id="divPostComment">
|
||||
<label for="commentairePost">commentaire du Poste : </label>
|
||||
<label for="commentairePost">Commentaire du poste : </label>
|
||||
<input type="text" id="commentairePost" name="commentairePost">
|
||||
</div>
|
||||
<div>
|
||||
<label for="recompense">Récompense : </label>
|
||||
<input type="text" id="recompense" name="recompense">
|
||||
</div>
|
||||
<button>Submit</button>
|
||||
</form>
|
||||
</li>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<%- include('includes/head.ejs', {Title: 'Campagne BDE'}) %>
|
||||
<link rel="stylesheet" type="text/css" href="css/hotLine.css">
|
||||
<script src="js/soumettrePost.js" defer></script>
|
||||
<head>
|
||||
<body>
|
||||
<%- include('includes/header') %>
|
||||
|
@ -7,6 +8,17 @@
|
|||
<video id="background-video" autoplay loop muted>
|
||||
<source src="video/videoBackground.mp4" type="video/mp4">
|
||||
</video>
|
||||
<div id="hiddenDiv">
|
||||
<h1>
|
||||
soumettre sa résolution
|
||||
</h1>
|
||||
<p>
|
||||
test
|
||||
</p>
|
||||
<form>
|
||||
<button>soumettre la résolution</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="first_div">
|
||||
<div>
|
||||
<h1>
|
||||
|
@ -52,13 +64,28 @@
|
|||
<p>
|
||||
<%= post.commentairePost %>
|
||||
</p>
|
||||
<p>
|
||||
Récompense : <%= post.recompense %>
|
||||
</p>
|
||||
<p>
|
||||
statue : Accepté
|
||||
</p>
|
||||
</div>
|
||||
<% } else {%>
|
||||
<div id="postNotFinish">
|
||||
<h2><%= post.titre %></h2>
|
||||
<p>
|
||||
<%= post.commentairePost %>
|
||||
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>
|
||||
<% } %>
|
||||
<% }); %>
|
||||
|
|
Loading…
Reference in a new issue