Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
a676f0a
1
Pedrocaloi Oct 14, 2022
f5c38b5
Merge branch 'dev' of https://github.com/facoogle/Nutri-APP into paym…
Pedrocaloi Oct 14, 2022
8c5f821
1
Pedrocaloi Oct 14, 2022
b0f460f
Merge pull request #6 from facoogle/profilecss
facoogle Oct 14, 2022
27b7fa7
Nuevo componente IMC
facoogle Oct 14, 2022
89b262b
Merge branch 'dev' into More2
facoogle Oct 14, 2022
529b2f2
nuevo componente
facoogle Oct 14, 2022
7cac444
Merge pull request #7 from facoogle/More2
LEANDROESPINASSE Oct 14, 2022
6941b4e
noanda
Pedrocaloi Oct 14, 2022
d083680
este si
Pedrocaloi Oct 14, 2022
290bce3
Merge pull request #8 from facoogle/paymentMethod
facoogle Oct 14, 2022
04b1247
falta dar estilos
Pedrocaloi Oct 14, 2022
061240a
Payment method con estilos
Pedrocaloi Oct 15, 2022
9aed1d8
Merge pull request #9 from facoogle/paymentMethod
facoogle Oct 15, 2022
c46d934
ADD Create Calculator
facoogle Oct 15, 2022
1da33c7
Merge pull request #10 from facoogle/calculator
Pedrocaloi Oct 15, 2022
7c00115
Paymenth con algo de estilos, ta medio feo
Pedrocaloi Oct 15, 2022
4c85752
Merge pull request #11 from facoogle/paymentMethod
facoogle Oct 15, 2022
47987b1
ahora si xd
Pedrocaloi Oct 16, 2022
c274b39
Merge pull request #12 from facoogle/paymentMethod
facoogle Oct 16, 2022
b1d2aaf
post
DuvanMerchan Oct 16, 2022
26de763
varios cambios
facoogle Oct 16, 2022
ad8ae43
Merge branch 'moreprofile' into dev
facoogle Oct 16, 2022
38cb777
ranking complete
DuvanMerchan Oct 16, 2022
a525c90
Merge pull request #14 from facoogle/ranking
facoogle Oct 16, 2022
1ed5ae1
profile
DuvanMerchan Oct 17, 2022
d3ce56a
Merge branch 'dev' of https://github.com/facoogle/Nutri-APP into ranking
DuvanMerchan Oct 17, 2022
0df1010
Merge pull request #15 from facoogle/ranking
facoogle Oct 17, 2022
effede3
mod
facoogle Oct 17, 2022
c0f814a
add profile info
facoogle Oct 17, 2022
b92ab68
add info user
facoogle Oct 17, 2022
571098c
Merge pull request #16 from facoogle/profilemoreinfo
LEANDROESPINASSE Oct 17, 2022
14e096a
css
DuvanMerchan Oct 17, 2022
0833303
Merge branch 'dev' of https://github.com/facoogle/Nutri-APP into ranking
DuvanMerchan Oct 17, 2022
dd7e33e
css
DuvanMerchan Oct 17, 2022
461be74
Merge pull request #17 from facoogle/ranking
LEANDROESPINASSE Oct 17, 2022
5496830
finalcss
LEANDROESPINASSE Oct 17, 2022
2d119e0
Merge pull request #18 from facoogle/finalcss
Pedrocaloi Oct 17, 2022
abbb22f
un poco de estilos al payment
Pedrocaloi Oct 17, 2022
bf1e587
Merge pull request #20 from facoogle/paymentMethod2
juanmartinezp Oct 17, 2022
15ac331
te envia el recibo por email
Pedrocaloi Oct 17, 2022
6bb47db
Merge pull request #21 from facoogle/paymentMethod2
juanmartinezp Oct 17, 2022
39f80e2
profilecss
LEANDROESPINASSE Oct 17, 2022
0071d69
Merge pull request #22 from facoogle/profilecss
juanmartinezp Oct 17, 2022
3a7576b
asdas
Pedrocaloi Oct 17, 2022
28b74a5
Merge pull request #23 from facoogle/paymentFix
Pedrocaloi Oct 17, 2022
10ce223
falta terminar de revisar
juanmartinezp Oct 17, 2022
c93a012
Merge branch 'dev' into recipes_admin
juanmartinezp Oct 17, 2022
170a1c0
profile imagen, falta
facoogle Oct 17, 2022
2e1ce55
Merge pull request #24 from facoogle/MoreImgProfile
LEANDROESPINASSE Oct 17, 2022
4b7625a
Merge pull request #25 from facoogle/dev
LEANDROESPINASSE Oct 17, 2022
ea76ec0
Merge pull request #26 from facoogle/recipes_admin
facoogle Oct 18, 2022
63046cc
Mod recipe in db
facoogle Oct 18, 2022
d7f2331
Merge pull request #27 from facoogle/recipeMod
facoogle Oct 18, 2022
50bd810
falta terminar
juanmartinezp Oct 18, 2022
8c39ad0
Merge branch 'dev' into action_admin
facoogle Oct 18, 2022
ee61cc4
Merge pull request #28 from facoogle/action_admin
facoogle Oct 18, 2022
9c2c372
falta terminar
juanmartinezp Oct 18, 2022
e2f5d23
Merge pull request #29 from facoogle/actionAdmin
facoogle Oct 18, 2022
61c34d2
add route ban recipe
facoogle Oct 18, 2022
d46e9f7
Merge pull request #30 from facoogle/routebanRecipe
juanmartinezp Oct 18, 2022
76ecc56
anda ponele
Pedrocaloi Oct 18, 2022
fab2032
Merge pull request #31 from facoogle/bannedFixPonele
LEANDROESPINASSE Oct 18, 2022
7be973e
dietas frot-back
DuvanMerchan Oct 18, 2022
4f96f3f
Merge pull request #32 from facoogle/ranking
Pedrocaloi Oct 18, 2022
36c8a92
Merge pull request #33 from facoogle/loader
LEANDROESPINASSE Oct 18, 2022
f6b7250
spinner en el payment
Pedrocaloi Oct 18, 2022
11e959f
listo
Pedrocaloi Oct 18, 2022
3d76732
Merge pull request #34 from facoogle/loader
LEANDROESPINASSE Oct 18, 2022
e8d59e8
your post reviewed css
LEANDROESPINASSE Oct 18, 2022
8ad2e4d
Merge pull request #35 from facoogle/profile
juanmartinezp Oct 18, 2022
b3bd031
FUNCIONAAAAAA GRACIAS JALU
juanmartinezp Oct 19, 2022
3504610
Merge branch 'dev' into user_admin
juanmartinezp Oct 19, 2022
0f65d25
Merge pull request #36 from facoogle/user_admin
LEANDROESPINASSE Oct 19, 2022
1b22072
Modificacion Calculator
facoogle Oct 19, 2022
d34e6cf
Merge pull request #37 from facoogle/csscalculatorxD
LEANDROESPINASSE Oct 19, 2022
d9f533a
bug fixed
juanmartinezp Oct 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const server = require('./src/app.js');
const { conn, Diet } = require('./src/db.js');
const {DB_PORT} = process.env
const dietTypes = require('./src/utils/apispoon')

const { getApi } = require("./src/getApiRecipes/getApiRecipe")
// import dietTypes from './src/utils/apispoon'

// Syncing all the models at once.
Expand All @@ -26,4 +26,6 @@ conn.sync({ alter: true }).then(() => {
})

});

getApi()
});
3 changes: 2 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"nodemailer": "^6.8.0",
"pg": "^8.8.0",
"sequelize": "^6.23.2",
"stripe": "^10.13.0"
"stripe": "^10.13.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"nodemon": "^2.0.20"
Expand Down
2 changes: 2 additions & 0 deletions api/src/controllers/recipecontrollers.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const updateRecipe = async (id) => {
}




module.exports = {
getApiRecipeByID,
createRecipe,
Expand Down
58 changes: 31 additions & 27 deletions api/src/controllers/recipescontrollers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,41 @@ const axios = require ("axios")
const { API_KEY } = process.env
const { Recipe, Diet } = require("../db.js")
// import dietTypes from '../utils/apispoon'
const uuid = require('uuid');



const getApiRecipes = async() => {
try {
// const getApiRecipes = async() => {
// try {

const axiosResponse = await axios.get(`https://api.spoonacular.com/recipes/complexSearch?apiKey=${API_KEY}&addRecipeInformation=true&number=100`)
const { results } = axiosResponse.data;
// const axiosResponse = await axios.get(`https://api.spoonacular.com/recipes/complexSearch?apiKey=${API_KEY}&addRecipeInformation=true&number=100`)
// const { results } = axiosResponse.data;

if(results !== 0 ) {
let dishRecipe = await results?.map((e) => {
return {
id: e.id,
name: e.title,
healthScore: e.healthScore,
image: e.image,
banned: e.banned,
summary: e.summary,
//cuisines: e.cuisines?.map(ele => ele),
//dishTypes: e.dishTypes?.map(ele => ele),
diets: e.diets?.map(ele => ele),
createdInDB: false
//ingredients: e.analyzedInstructions[0].steps?.map(ele => ele.ingredients.name): "does not have any ingredient"
}
})
return dishRecipe
}
// if(results !== 0 ) {
// let dishRecipe = await results?.map((e) => {
// return {
// //id: uuid.v4(),
// id: e.id,
// name: e.title,
// healthScore: e.healthScore,
// image: e.image,
// banned: e.banned,
// summary: e.summary,
// //cuisines: e.cuisines?.map(ele => ele),
// //dishTypes: e.dishTypes?.map(ele => ele),
// diets: e.diets?.map(ele => ele),
// createdInDB: false
// //ingredients: e.analyzedInstructions[0].steps?.map(ele => ele.ingredients.name): "does not have any ingredient"
// }
// })
// return dishRecipe
// }

// } catch(error) {
// console.log(error)
// }
// }

} catch(error) {
console.log(error)
}
}


const getDBRecipes = async() => {
Expand Down Expand Up @@ -72,6 +75,7 @@ const getApiNameRecipes = async(name) => {
if(results !==0) {
let dishName = results?.map((el) => {
return {

id: el.id,
name: el.title,
healthScore: el.healthScore,
Expand Down Expand Up @@ -124,7 +128,7 @@ const getDBNameRecipes = async(name) => {

const getAllInfo = async() => {
try {
let data = await getApiRecipes()
let data //await getApiRecipes()
let dbData = await getDBRecipes()
if(!dbData || dbData.length === 0) {

Expand Down
156 changes: 156 additions & 0 deletions api/src/controllers/usersControllers/PostRanking.controllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
const { User, Post, Recipe, Ranking } = require("../../db");

const getAllPost = async (userId) =>{
try {
let user = await User.findByPk(userId, { include: Post } )
let posts = user.posts
let post =[]
// console.log('user',user);
// console.log('posts',posts);
//return await User.findByPk(userId, { include: Post } )
if (posts) {
await Promise.allSettled(
await posts.map(async p=>{
let recipe = await Recipe.findByPk(p.recipeId)
post.push({
userId:p.dataValues.id,
username: user.dataValues.username,
content:p.dataValues.content,
recipeId: recipe.dataValues.id,
recipeImg:recipe.dataValues.image,
recipeName:recipe.dataValues.name,
})}))
console.log('post',post);
return post
}

} catch (error) {
console.log(error)
}}

const getRecipePost = async (recipeId) =>{
try {
let {posts} = await Recipe.findByPk(recipeId, { include: Post } )
let post = []
if(posts){
await Promise.allSettled(
await posts.map( async( p)=>{
let user = await User.findByPk(p.userId)
post.push( {
username:user.dataValues.username,
post: p.dataValues,
})}))
return post
}
} catch (error) {
console.log(error)
}}

const createPost =async (userId, content,recipeId) =>{
try {
let user = await User.findByPk(userId)
let recipe = await Recipe.findByPk(recipeId)
let newPost = await Post.create({
content,
userId,
recipeId,})

await user.addPost(newPost)
await recipe.addPost(newPost)
return await User.findByPk(userId, { include: Post } )
} catch (error) {
console.log(error)
}}

const countRanking = async (recipeId) =>{
try {
let {count, rows} = await Ranking.findAndCountAll({
where:{recipeId:recipeId}
})
let sum = 0
rows.forEach(ele => {
sum = sum + ele.dataValues.ranking
});
return sum/count

} catch (error) {
console.log(error)
}
}
const getUserRanking =async(userId , recipeId)=>{
try {
let rank = await findOne({
where:{
userId,recipeId
}})
return rank
} catch (error) {
console.log(error)
}
}

const addRanking =async (userId , recipeId, ranking) =>{
try {
let user = await User.findByPk(userId)
let recipe = await Recipe.findByPk(recipeId)
let rank = await Ranking.findOne({
where:{
userId,recipeId
}
})
if (!user || !recipe) {
throw new Error('need more data')
}else{
if (rank) {
return await rank.update({ranking:ranking})
} else {
let newRanking = await Ranking.create({
ranking,
userId,
recipeId})
await user.addRanking(newRanking)
await recipe.addRanking(newRanking)
return await Recipe.findByPk(recipeId, { include: Ranking } )
}}
} catch (error) {
console.log(error)
}
}

const updatePost =async (postId,content) =>{
try {
let post = await Post.findByPk(postId)
return await post.update({content:content})
} catch (error) {
console.log(error)
}
}
const updateRanking =async (ranking, rankingId) =>{
try {
let rank = await Ranking.findByPk(rankingId)
return await rank.update({ranking:ranking})
} catch (error) {
console.log(error)
}
}
const deletePost =async (postId) =>{
try {
let post = await Post.findByPk(postId)
await post.destroy()
return('The post was delete')
} catch (error) {
console.log(error)
}
}

module.exports ={
getAllPost,
createPost,
getRecipePost,
getUserRanking,
addRanking,
countRanking,
updateRanking,
updatePost,
deletePost
}
15 changes: 13 additions & 2 deletions api/src/controllers/usersControllers/admin.controllers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { User, Favorites } = require("../../db.js");
const { User, Favorites, Recipe } = require("../../db.js");
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
const authConfig = require('../config/auth.js')
Expand Down Expand Up @@ -89,6 +89,16 @@ const userBanned =async(id,banned) =>{
}
}

const recipeBanned =async(id,banned) =>{
try {
let recipe = await Recipe.findByPk(id)
await recipe.update({banned: banned})
return recipe
} catch (error) {
console.log(error)
}
}

const defaultList = async (user) =>{
let defList = await Favorites.create({
userId: user.id
Expand All @@ -103,5 +113,6 @@ module.exports = {
usersList,
userByid,
userByName,
userBanned
userBanned,
recipeBanned
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(banned.toString() == "false"){
from: "nutri.u.contact@gmail.com",
to: email,
subject:"Your nutri-u account has been unbanned",
html:`<p>Your account has been unbanned for administrator<a href="nutri.u.contact@gmail.com">nutri.u.contact@gmail.com</a></p>`,
html:`<p>Your account has been unbanned for administrator <a href="nutri.u.contact@gmail.com">nutri.u.contact@gmail.com</a></p>`,
})
}

Expand All @@ -27,7 +27,7 @@ if(banned.toString() == "true") {
from: "nutri.u.contact@gmail.com",
to: email,
subject:"Your nutri-u account has been banned",
html:`<p>You were blocked by a Nutri-u administrator, if you see that this was an error, contact this email<a href="nutri.u.contact@gmail.com">nutri.u.contact@gmail.com</a></p>`,
html:`<p>You were blocked by a Nutri-u administrator, if you see that this was an error, contact this email <a href="nutri.u.contact@gmail.com">nutri.u.contact@gmail.com</a></p>`,
})
}

Expand Down Expand Up @@ -58,9 +58,28 @@ if(email && token){

}

async function paymentNotification(email, recibo){
let transporter = nodemailer.createTransport({
host: `${HOST_EMAIL}`,
port:`${PORT_EMAIL}`,
secure:false,
auth:{
user:`${EMAIL}`,
pass:`${EMAIL_PASS}`
}
});
return transporter.sendMail({
from: "nutri.u.contact@gmail.com",
to: email,
subject:"Your suscription to Nutri-U has been successful!",
html:`<p>You are a Premium User now, enjoy!<br/> <br/>You can download your invoice here: <br/> ${recibo}<a href="nutri.u.contact@gmail.com">nutri.u.contact@gmail.com</a></p>`,
})

}

module.exports = {
//adminLogin,
bannedUserNotification,
changePasswordNotification
changePasswordNotification,
paymentNotification
}
Loading