Skip to content

Commit

Permalink
everything but put and delete
Browse files Browse the repository at this point in the history
  • Loading branch information
makon57 committed Jul 1, 2021
1 parent 886e624 commit 4815e3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
24 changes: 14 additions & 10 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,21 @@ router.put(
})
);

// router.delete('/:id(\\d+)', asyncHandler(async(req, res, next) => {
// const tweetId = req.params.id;
// const tweet = await Tweet.findByPk(tweetId);
router.delete('/trail/:id(\\d+)', asyncHandler(async(req, res, next) => {
const trailId = req.params.id;
const review = await db.Review.findAll({ where: { trailId }, include: "User" })

// if (tweet) {
// await tweet.destroy();
// res.status(201).end();
// } else {
// next(tweetNotFound(tweetId));
// }
// }));
await review.destroy();
}));

// router.delete('/trail/:id', function (req, res) {
// console.log("DELETE review")
// Review.findByIdAndRemove(req.params.id).then((review) => {
// res.redirect('/');
// }).catch((err) => {
// console.log(err.message);
// })
// })


router.post('/', (req, res) => {
Expand Down
6 changes: 5 additions & 1 deletion views/trail-detail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ block content
p(class="review-username")= `User: ${review.User.username}`
p(class="review-text")= `${review.text}`
p(class="review-date")= `Reviewed at: ${review.createdAt}`
button(type="submit" class="edit-btn") Edit Review
button(type="submit" class="edit-btn hi") Edit Review
p
form(action=`/trail/${trail.id}` method="delete" class="")
button(type="submit" class="delete-btn hi") Delete Review

//- input(type="hidden" class="edit-input")
//- if (review.User.id === review.userId)
Expand Down

0 comments on commit 4815e3a

Please sign in to comment.