-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes
More file actions
81 lines (65 loc) · 3.21 KB
/
notes
File metadata and controls
81 lines (65 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
router.delete('/:id', async(req, res) => {
try {
const review = await db.review.findByPk(req.params.id)
const recipe = await review.getRecipe()
let recipeUsers = []
let newRecipeReviews = []
const recipeReviews = await recipe.getReviews({include: db.user})
recipeUsers = await recipe.getReviews({include: db.user})
// console.log(recipeReviews)
// console.log(`🔥 🔥 🔥 ${recipeReviews}`)
// console.log(`😇 😇 😇 ${recipe}`)
// console.log(`🍓 🍓 🍓 ${review}`)
//hold the reviews I need to keep in an array like hug
recipeReviews.forEach(recipeReview => {
if (recipeReview.id !== review.id) {
// console.log(recipeReview)
// console.log(review)
newRecipeReviews.push(recipeReview)
}
})
await review.destroy()
res.render('recipes/detail', {
recipe: recipe,
reviews: newRecipeReviews,
users: recipeUsers
})
} catch (error) {
console.log(error)
}
})
<% if (more) { %>
<p>showing <%= from %> to <%= to %> results</p>
<form action="/recipes/results" method="GET">
<input type="submit" value="Show More Results">
</form>
<% } %>
<!-- <form action="/recipes" method="POST">
<input type="hidden" name="label" value="<%= recipe.dataValues.label %>">
<input type="hidden" name="uri" value="<%= recipe.dataValues.uri %>">
<input type="hidden" name="image" value="<%= recipe.dataValues.image %>">
<input type="hidden" name="source" value="<%= recipe.dataValues.source %>">
<input type="hidden" name="url" value="<%= recipe.dataValues.url %>">
<input type="hidden" name="ingredientLines" value="<%= recipe.dataValues.ingredientLines %>">
<input type="hidden" name="cautions" value="<%= recipe.dataValues.cautions %>">
<input type="hidden" name="dietLabels" value="<%= recipe.dataValues.dietLabels %>">
<input type="hidden" name="healthLabels" value="<%= recipe.dataValues.healthLabels %>">
</form>
-->
<!-- <form action="/recipes" method="POST">
<input type="hidden" name="label" value="<%= hit.recipe.label %>">
<input type="hidden" name="uri" value="<%= hit.recipe.uri %>">
<input type="hidden" name="image" value="<%= hit.recipe.image %>">
<input type="hidden" name="source" value="<%= hit.recipe.source %>">
<input type="hidden" name="url" value="<%= hit.recipe.url %>">
<input type="hidden" name="ingredientLines" value="<%= hit.recipe.ingredientLines %>">
<input type="hidden" name="cautions" value="<%= hit.recipe.cautions %>">
<input type="hidden" name="dietLabels" value="<%= hit.recipe.dietLabels %>">
<input type="hidden" name="healthLabels" value="<%= hit.recipe.healthLabels %>">
</form> -->
<% if (more) { %>
<p>showing <%= from %> to <%= to %> results</p>
<form action="/recipes/results" method="GET">
<input type="submit" value="Show More Results">
</form>
<% } %>