|
|
|
@ -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; |