Skip to content

Commit

Permalink
last revision v.1 b00tc4mp#407
Browse files Browse the repository at this point in the history
  • Loading branch information
berlem committed Apr 26, 2024
1 parent 7242b13 commit 81037dc
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const retrieveFavRecipesHandler = async (req, res) => {

const payload = jwt.verify(token, process.env.JWT_SECRET)
const { sub: userId } = payload
console.log(userId)

try {
validate.id(userId, 'id')
Expand Down
9 changes: 0 additions & 9 deletions staff/belen-ivars/project/api/logic/editRecipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ export default async function editRecipe(userId, recipeId, title, description, i
} catch (error) {
throw new SystemError(error.message)
}
console.log('títol bé')

if (description)
try {
recipeUpdated = await Recipe.findOneAndUpdate({ _id: recipe.id }, { description: description })
} catch (error) {
throw new SystemError(error.message)
}
console.log('descripció')


if (image)
Expand All @@ -60,7 +58,6 @@ export default async function editRecipe(userId, recipeId, title, description, i
} catch (error) {
throw new SystemError(error.message)
}
console.log('image')


if (ingredients) {
Expand All @@ -77,13 +74,10 @@ export default async function editRecipe(userId, recipeId, title, description, i
}

try {
console.log(recipe.id, 'hay recipe.id?')
recipeUpdated = await Recipe.findOneAndUpdate({ _id: recipe.id }, { ingredients: ingredientsOfThisRecipe })
console.log(ingredientsOfThisRecipe)
} catch (error) {
throw new SystemError(error.message)
}
console.log('ingredients')
}


Expand All @@ -93,7 +87,6 @@ export default async function editRecipe(userId, recipeId, title, description, i
} catch (error) {
throw new SystemError(error.message)
}
console.log('dieta')


if (complexity)
Expand All @@ -102,7 +95,6 @@ export default async function editRecipe(userId, recipeId, title, description, i
} catch (error) {
throw new SystemError(error.message)
}
console.log('complexitat')


if (method)
Expand All @@ -111,7 +103,6 @@ export default async function editRecipe(userId, recipeId, title, description, i
} catch (error) {
throw new SystemError(error.message)
}
console.log('mètode')



Expand Down
27 changes: 12 additions & 15 deletions staff/belen-ivars/project/api/logic/editRecipe.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,36 @@ describe('editRecipe', () => {
const description = random.text()
const image = random.image()

const ingredients = []
const ingredient1 = random.ingredientName()
const ingredient2 = random.ingredientName()
const ingredient3 = random.ingredientName()
ingredients.push(ingredient1, ingredient2, ingredient3)
console.log(ingredients)
const ingredients2 = []
const ingredient4 = random.ingredientName()
const ingredient5 = random.ingredientName()
const ingredient6 = random.ingredientName()
ingredients2.push(ingredient4, ingredient5, ingredient6)

const diet = random.diet()
const complexity = random.complexity()
const method = random.method()

const author = user.id

let recipe = await Recipe.create({ author, title, description, image, ingredients, diet, complexity, method })
let recipe = await Recipe.create({ author, title, description, image, ingredients2, diet, complexity, method })

const title2 = random.name()
const description2 = random.text()
const image2 = random.image()

const ingredients2 = []
const ingredient4 = random.ingredientName()
const ingredient5 = random.ingredientName()
const ingredient6 = random.ingredientName()
ingredients2.push(ingredient4, ingredient5, ingredient6)
console.log(ingredients2)
const ingredient1 = random.ingredientName()
const ingredient2 = random.ingredientName()
const ingredient3 = random.ingredientName()
const ingredients = `${ingredient1}, ${ingredient2}, ${ingredient3}`

const diet2 = random.diet()
const complexity2 = random.complexity()
const method2 = random.method()
console.log(recipe.id)

let recipeEdited
try {
recipeEdited = await editRecipe(user.id, recipe.id, title2, description2, image2, ingredients2, diet2, complexity2, method2)
recipeEdited = await editRecipe(user.id, recipe.id, title2, description2, image2, ingredients, diet2, complexity2, method2)
} catch (error) {
expect(recipeEdited).to.be.exist
expect(recipeEdited.title).to.equal(title2)
Expand Down
2 changes: 1 addition & 1 deletion staff/belen-ivars/project/app/src/components/NewSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function NewSearch(props) {
function handleSubmit(event) {
event.preventDefault()

const ingredients = event.target.querySelector('#search-elements').value
const ingredients = event.target.querySelector('#search-elements').value.toLowerCase()
if (ingredients.length > 0) {
const formatedIngredients = ingredients.split(', ').join('-')
props.setIngredients(formatedIngredients)
Expand Down
1 change: 0 additions & 1 deletion staff/belen-ivars/project/app/src/components/Recipe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function Recipe(props) {
await logic.toggleFavRecipe(props.recipe._id)
props.recipe.fav = !props.recipe.fav
props.onSuccess()
console.log('fav done')

} catch (error) {
context.handleError(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ async function getIngredientsList(recipeId) {

try {
const ingredientsList = await res.json()
console.log('estic en lògica front')
return ingredientsList
} catch (error) {
throw new SystemError(error.message)
Expand Down
2 changes: 0 additions & 2 deletions staff/belen-ivars/project/app/src/logic/logoutUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ export default function logoutUser() {
session.token = null
session.sessionUserId = null


console.log('logging out')
}
1 change: 0 additions & 1 deletion staff/belen-ivars/project/app/src/logic/searchRecipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default async function searchRecipes(ingredients, diet, complexity, metho

let res
try {
console.log(query, 'query')
res = await fetch(`${API_URL}/recipes/search?${query}`, req)
} catch (error) {
throw new SystemError(error.message)
Expand Down
6 changes: 3 additions & 3 deletions staff/belen-ivars/project/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In this application you can add and find different recipes, simple, and made up
It's the kitchen basic wardrobe.

### Use Cases
- Display the recipes.
- Display recipes.
- Add new recipes.
- Filter recipes by ingredients.
- Filter recipes by elaboration duration.
Expand Down Expand Up @@ -48,11 +48,11 @@ It's the kitchen basic wardrobe.
* description (string)
* image (image)
* ingredients (array of Ingredient.id)
* elaborationDuration (number)
* elaborationDuration (number) (v.2)
* feedType (string, enum: glutenfree, vegetarian, vegan)
* complexityLevel (string, enum: easy, regular, complex)
* cookingType (string, enum: steamed, oven, microwave, grill, fresh, cooked)
* date (date)
* date (date) (v.2)

#### Review (v.2)
* id (string)
Expand Down

0 comments on commit 81037dc

Please sign in to comment.