From d3cca88f894da19744ea7ff9ce9cafa314c3106e Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 08:32:06 -0300 Subject: [PATCH 01/60] =?UTF-8?q?Actualizo=20ruta=20para=20borrado=20l?= =?UTF-8?q?=C3=B3gico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/routes/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/routes/index.js b/server/src/routes/index.js index f5c4bd5..e083a72 100644 --- a/server/src/routes/index.js +++ b/server/src/routes/index.js @@ -34,10 +34,10 @@ function isAuthorized(req, res, next) { router.get("/", isAuthenticated); -router.delete('/users/:id',isAuthenticated, isAuthorized, Controller.deleteUser) +router.delete('/users/:id', Controller.deleteUser) -router.put('/users/restore/:id',isAuthenticated, isAuthorized, Controller.restoreUser) +router.put('/users/restore/:id',Controller.restoreUser) router.get('/users/:id/dashboard', Controller.getUserDashboard) From c04001fd36b2b56e127afc4ee1f6ac448d9558e8 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 09:13:18 -0300 Subject: [PATCH 02/60] Corrigo buf detail --- server/src/controllers/projects.js | 2 +- server/src/services/projects.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/server/src/controllers/projects.js b/server/src/controllers/projects.js index 3db1e99..cc38c5b 100644 --- a/server/src/controllers/projects.js +++ b/server/src/controllers/projects.js @@ -17,7 +17,7 @@ const projectControllers = { getProjectsID: async function (req,res) { try { const {id} = req.params - const projectDetail = await Services.projectId(id) + const projectDetail = await Services.getProjectById(id) res.status(200).json(projectDetail) } catch (error) { res.status(500).json(error.message) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index d1aac6e..d231ca0 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -128,6 +128,24 @@ const ProjectServices = { return error; } }, + + getProjectById: async function(id){ + const project = await Projects.findByPk(id, { + include: [ + { + model: Category, + attributes: ["name"], + through: { attributes: [] }, + }, + { + model: Users, + attributes: ["name"], + }, + ], + }); + return project; + }, + createProjects: async function (projectData) { try { const { From 8b1d3d795d611008b9c925dfa9197c58ad419195 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 16:50:22 -0300 Subject: [PATCH 03/60] Agrego notificaciones a users y projects --- server/package-lock.json | 9 ++++++++ server/package.json | 1 + server/src/controllers/form.js | 13 +++++++++++- server/src/controllers/mailer.js | 35 ++++++++++++++++++++++++++++++++ server/src/controllers/users.js | 7 +++++++ 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 server/src/controllers/mailer.js diff --git a/server/package-lock.json b/server/package-lock.json index 08ee94e..d11877c 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -24,6 +24,7 @@ "mercadopago": "^1.5.17", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", + "nodemailer": "^6.9.7", "nodemon": "^2.0.22", "npm-run-all": "^4.1.5", "passport": "^0.6.0", @@ -3531,6 +3532,14 @@ "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, + "node_modules/nodemailer": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.7.tgz", + "integrity": "sha512-rUtR77ksqex/eZRLmQ21LKVH5nAAsVicAtAYudK7JgwenEDZ0UIQ1adUGqErz7sMkWYxWTTU1aeP2Jga6WQyJw==", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/nodemon": { "version": "2.0.22", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz", diff --git a/server/package.json b/server/package.json index 9be00c8..90adbeb 100644 --- a/server/package.json +++ b/server/package.json @@ -24,6 +24,7 @@ "mercadopago": "^1.5.17", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", + "nodemailer": "^6.9.7", "nodemon": "^2.0.22", "npm-run-all": "^4.1.5", "passport": "^0.6.0", diff --git a/server/src/controllers/form.js b/server/src/controllers/form.js index 028f626..896813a 100644 --- a/server/src/controllers/form.js +++ b/server/src/controllers/form.js @@ -1,4 +1,6 @@ const { ProjectServices } = require("../services"); +const {sendEmail} = require("./mailer"); +const { Users } = require('../db'); @@ -10,9 +12,18 @@ const formControllers = { const post = { ...projectData, }; - console.log(projectData); const newProject = await ProjectServices.createProjects(post); + + const user = await Users.findByPk(projectData.userId); + + + const userMail = user.email + const subject = "Proyecto creado con éxito ✔"; + const text = `Querido ${user.name} Tu proyecto se ha creado con éxito. Felicitaciones y gracias por hacer de nuestra comunidad un lugar mejor! ` + const html = "Tu nuevo proyecto ya está ONLINE! 😂 " + sendEmail(userMail, subject, text, html) + res.status(200).json(newProject); console.log(newProject); } catch (error) { diff --git a/server/src/controllers/mailer.js b/server/src/controllers/mailer.js new file mode 100644 index 0000000..bdbdfbc --- /dev/null +++ b/server/src/controllers/mailer.js @@ -0,0 +1,35 @@ +const nodemailer = require('nodemailer'); + +const { + MAIL_USERNAME, + MAIL_PASSWORD +} = process.env + +const transporter = nodemailer.createTransport({ + host: "smtp.gmail.com", + port:465, + secure:true, + auth:{ + user: MAIL_USERNAME, + pass: MAIL_PASSWORD + } +}); + +const sendEmail = async(to, subject, text, html)=>{ + const mailOptions={ + from: MAIL_USERNAME, + to, + subject, + text, + html + }; + + try{ + await transporter.sendMail(mailOptions); + console.log(`Correo electrónico enviado a ${to}`); + }catch (error){ + console.log("Error al enviar el correo electrónico", error); + } +} + +module.exports = {sendEmail} diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index 1708413..4949688 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -1,4 +1,5 @@ const Service = require('../services').userServices; +const { sendEmail } = require('./mailer'); const userControllers = { getUsers: async function (req,res) { @@ -13,6 +14,12 @@ const userControllers = { postUser: async function (req,res) { try { const Users = await Service.createUser(req.body) + const userMail = Users.email + const subject = "Usuario creado con éxito ✔"; + const text = `Hola ${Users.name}, te damos la bienvenida a PROJUNITY!.`; + const html = "Bievenido a la comunidad de PROJUNITY!" + sendEmail(userMail, subject, text, html) + res.status(200).json(Users) } catch (error) { res.status(500).json(error.message) From f65e0b2b103c87bd7bb663c707b40a574ca878e5 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 23:04:04 -0300 Subject: [PATCH 04/60] Actualizo detail --- server/src/services/projects.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index d231ca0..df23d71 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -138,9 +138,28 @@ const ProjectServices = { through: { attributes: [] }, }, { - model: Users, + model: Tags, attributes: ["name"], + where: condition.tag, + through: { attributes: [] }, }, + { + model: Ratings, + attributes: ["score", "comment"], + where: condition.rating, + through: { attributes:[] } , + }, + { + model: Comments, + attributes: ['id', 'comment', 'replyTo'], + through: {attributes: []} + }, + { + model: Users, + attributes: ['id','name','email','githubUser','twitterUser','linkedinUser'], + where: condition.users, + through: {attributes: []} + } ], }); return project; From 539d2bb12f3d97e72e403ae6421431f79c8718ca Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 23:08:26 -0300 Subject: [PATCH 05/60] A --- server/src/services/projects.js | 76 ++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index df23d71..c9c45d9 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -129,40 +129,48 @@ const ProjectServices = { } }, - getProjectById: async function(id){ - const project = await Projects.findByPk(id, { - include: [ - { - model: Category, - attributes: ["name"], - through: { attributes: [] }, - }, - { - model: Tags, - attributes: ["name"], - where: condition.tag, - through: { attributes: [] }, - }, - { - model: Ratings, - attributes: ["score", "comment"], - where: condition.rating, - through: { attributes:[] } , - }, - { - model: Comments, - attributes: ['id', 'comment', 'replyTo'], - through: {attributes: []} - }, - { - model: Users, - attributes: ['id','name','email','githubUser','twitterUser','linkedinUser'], - where: condition.users, - through: {attributes: []} - } - ], - }); - return project; + getProjectsID: async function (id) { + try { + const ProjectId = await Projects.findOne({ + where: { id: id }, + include: [ + { + model: Category, + attributes: ["name"], + through: { attributes: [] }, + }, + { + model: Tags, + attributes: ["name"], + through: { attributes: [] }, + }, + { + model: Comments, + attributes: ["id", "comment", "replyTo"], + through: { attributes: [] }, + }, + { + model: Ratings, + attributes: ["score", "comment"], + /* where: condition.rating, */ + through: { attributes: [] }, + }, + { + model: Users, + attributes: ["id", "name", "email"], + /* where: condition.users, */ + through: { attributes: [] }, + }, + ], + }); + if (ProjectId) { + return ProjectId; + } else { + throw Error(`Id ${id} no encontrado`); + } + } catch (error) { + return error; + } }, createProjects: async function (projectData) { From 594149064de94f351431d8ef21f7ed8b29aeaa4e Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 23:11:57 -0300 Subject: [PATCH 06/60] Face --- server/src/controllers/projects.js | 2 +- server/src/services/projects.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/controllers/projects.js b/server/src/controllers/projects.js index cc38c5b..1219bfc 100644 --- a/server/src/controllers/projects.js +++ b/server/src/controllers/projects.js @@ -17,7 +17,7 @@ const projectControllers = { getProjectsID: async function (req,res) { try { const {id} = req.params - const projectDetail = await Services.getProjectById(id) + const projectDetail = await Services.getProjectsByID(id) res.status(200).json(projectDetail) } catch (error) { res.status(500).json(error.message) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index c9c45d9..52be738 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -129,7 +129,7 @@ const ProjectServices = { } }, - getProjectsID: async function (id) { + getProjectsByID: async function (id) { try { const ProjectId = await Projects.findOne({ where: { id: id }, From f96d24f1969d6f45616afb321046a359aa34e7df Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 23:20:48 -0300 Subject: [PATCH 07/60] Corrijo bug detail --- server/src/controllers/projects.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/controllers/projects.js b/server/src/controllers/projects.js index 1219bfc..00311f8 100644 --- a/server/src/controllers/projects.js +++ b/server/src/controllers/projects.js @@ -23,6 +23,7 @@ getProjectsID: async function (req,res) { res.status(500).json(error.message) } }, + putProjects: async function (req, res) { try { const projectId = req.params.id; From 909ea330b6955dc252fad088022ab07ab3a5cf04 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Wed, 25 Oct 2023 01:39:26 -0300 Subject: [PATCH 08/60] =?UTF-8?q?Actualizo=20borrado=20l=C3=B3gico=20de=20?= =?UTF-8?q?proyectos=20y=20usuarios=20para=20admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controllers/projects.js | 10 +++++- server/src/controllers/users.js | 14 ++++++-- server/src/models/projects.js | 5 ++- server/src/models/user.js | 5 ++- server/src/routes/index.js | 5 ++- server/src/services/Users.js | 25 ++++++++++---- server/src/services/projects.js | 54 +++++++++++++++++++++++++++--- 7 files changed, 102 insertions(+), 16 deletions(-) diff --git a/server/src/controllers/projects.js b/server/src/controllers/projects.js index 00311f8..2ab4752 100644 --- a/server/src/controllers/projects.js +++ b/server/src/controllers/projects.js @@ -48,11 +48,19 @@ getProjectsID: async function (req,res) { const result = await Services.deleteProject(projectId); res.status(200).json(result); + } catch (error) { res.status(500).json(error.message); } }, - + getDeletedProjects: async function (req, res) { + try { + const deletedProjects = await Services.getDeletedProjects(); + res.status(200).json(deletedProjects); + } catch (error) { + res.status(500).json(error.message); + } + }, restoreProject : async function (req, res) { try{ const projectId = req.params.id; diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index 4949688..def5f3c 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -30,13 +30,23 @@ const userControllers = { try { const userId = req.params.id; - const result = await Service.deleteUser(userId); - + const result = await Service.deleteUserbyId(userId); + res.status(200).json(result); } catch (error) { res.status(500).json(error.message); } }, + + getDeletedUsers: async function (req, res) { + try { + const deletedUsers = await Service.getDeletedUsers(); + res.status(200).json(deletedUsers); + } catch (error) { + res.status(500).json(error.message); + } + }, + restoreUser : async function (req, res) { try{ diff --git a/server/src/models/projects.js b/server/src/models/projects.js index f86192b..3d9ecbd 100644 --- a/server/src/models/projects.js +++ b/server/src/models/projects.js @@ -12,6 +12,10 @@ sequelize.define('Projects', { type: DataTypes.TEXT, allowNull: false, }, + deleted: { + type: DataTypes.BOOLEAN, + defaultValue: false + }, price: { type: DataTypes.DECIMAL(11,2), allowNull: false, @@ -49,7 +53,6 @@ sequelize.define('Projects', { }, { timestamps: true, - paranoid: true, freezeTableName: true } ); diff --git a/server/src/models/user.js b/server/src/models/user.js index 41b870c..ad2e130 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -36,6 +36,10 @@ module.exports = (sequelize) => { type: DataTypes.STRING, allowNull: true }, + deleted: { + type: DataTypes.BOOLEAN, + defaultValue: false + }, emailUser: { type: DataTypes.STRING, unique: true, @@ -58,7 +62,6 @@ module.exports = (sequelize) => { }, { timestamps: true, - paranoid: true, freezeTableName: true }); }; \ No newline at end of file diff --git a/server/src/routes/index.js b/server/src/routes/index.js index e083a72..68a125d 100644 --- a/server/src/routes/index.js +++ b/server/src/routes/index.js @@ -36,11 +36,12 @@ router.get("/", isAuthenticated); router.delete('/users/:id', Controller.deleteUser) - router.put('/users/restore/:id',Controller.restoreUser) + router.get('/users/:id/dashboard', Controller.getUserDashboard) +router.get('/deleted-users', Controller.getDeletedUsers); router.post("/sign-up", Controller.postUser); @@ -64,12 +65,14 @@ router .get(Controller.getProjects) .post(Controller.createNewProject); + router .route("/projects/:id") .put(Controller.putProjects) .delete( Controller.deleteProject) router.put('/projects/restore/:id', Controller.restoreProject) +router.get('/deleted-projects', Controller.getDeletedProjects); diff --git a/server/src/services/Users.js b/server/src/services/Users.js index 1ab8667..2ae83d2 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -37,13 +37,13 @@ const userServices = { [Op.or]: [ {name: {[Op.iLike]: `${name}%`}}, ], - [Op.and]: [{active: 'true'}]}, + [Op.and]: [{deleted: 'false'}]}, attributes: ['id', 'name','email', 'image', 'twitterUser','emailUser','githubUser','linkedinUser','role'] }) return response } else { const response = await Users.findAll({ - where: {active: 'true'}, + where: {deleted: 'false'}, attributes: ['id','name','email', 'image', 'twitterUser','emailUser','githubUser', 'linkedinUser','role'] }) return response @@ -122,26 +122,39 @@ const userServices = { return error; } }, - deleteUser: async function(userId) { + deleteUserbyId: async function(userId) { try { const user = await Users.findByPk(userId); if (!user) { throw new Error('User not found'); } - await user.destroy(); + await user.update({ deleted: true }); return { message: 'User deleted successfully' }; } catch (error) { throw new Error(error.message); } }, + getDeletedUsers: async function () { + try { + const deletedUsers = await Users.findAll({ + where: { deleted: true }, + attributes: ['id', 'name', 'email', 'image', 'twitterUser', 'emailUser', 'githubUser', 'linkedinUser', 'role'] + }); + + return deletedUsers; + } catch (error) { + throw new Error(error.message); + } + }, + restoreUsers: async function(userId) { try { - const user = await Users.findByPk(userId, { paranoid: false }); + const user = await Users.findByPk(userId); if (!user) { throw new Error('User not found'); } - await user.restore(); + await user.update({ deleted: false }); return { message: 'User restored successfully' }; } catch (error) { throw new Error(error.message); diff --git a/server/src/services/projects.js b/server/src/services/projects.js index 52be738..c7126b3 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -88,6 +88,11 @@ const ProjectServices = { } }) : null; + + condition.project = { + ...condition.project, + deleted: false, + }; const projectsFilter = await Projects.findAll({ include: [ @@ -132,7 +137,7 @@ const ProjectServices = { getProjectsByID: async function (id) { try { const ProjectId = await Projects.findOne({ - where: { id: id }, + where: { id: id, deleted: false }, include: [ { model: Category, @@ -308,20 +313,61 @@ const ProjectServices = { if (!project) { throw new Error('Project not found'); } - await project.destroy(); + await project.update({ deleted: true }); return { message: 'Project deleted successfully' }; } catch (error) { throw new Error(error.message); } }, + getDeletedProjects: async function () { + try { + const deletedProjects = await Projects.findAll({ + where: { deleted: true }, + include: [ + { + model: Category, + attributes: ["name"], + through: { attributes: [] }, + }, + { + model: Tags, + attributes: ["name"], + through: { attributes: [] }, + }, + { + model: Comments, + attributes: ["id", "comment", "replyTo"], + through: { attributes: [] }, + }, + { + model: Ratings, + attributes: ["score", "comment"], + /* where: condition.rating, */ + through: { attributes: [] }, + }, + { + model: Users, + attributes: ["id", "name", "email"], + /* where: condition.users, */ + through: { attributes: [] }, + }, + ], + }); + + return deletedProjects; + } catch (error) { + return error; + } +}, + restoreProjects: async function(projectId) { try { - const project = await Projects.findByPk(projectId, { paranoid: false }); + const project = await Projects.findByPk(projectId); if (!project) { throw new Error('Project not found'); } - await project.restore(); + await project.update({ deleted: false }); return { message: 'Project restored successfully' }; } catch (error) { throw new Error(error.message); From 4cf501717911fa114a3eb9e1ec4c999c1fdd5adb Mon Sep 17 00:00:00 2001 From: jesib03 Date: Wed, 25 Oct 2023 17:09:23 -0300 Subject: [PATCH 09/60] gestionUsers --- front/components/admin/HeadAndFooter.jsx | 25 ++++-- front/pages/admin/gestionUsers.jsx | 13 ++- front/pages/admin/index.js | 2 +- front/redux/reducers/dashboardReducer.js | 3 +- front/redux/types.js | 4 +- server/package-lock.json | 108 +++++++++++++++++++++++ server/package.json | 3 +- server/src/db.js | 12 +-- 8 files changed, 146 insertions(+), 24 deletions(-) diff --git a/front/components/admin/HeadAndFooter.jsx b/front/components/admin/HeadAndFooter.jsx index 06606af..92f92e1 100644 --- a/front/components/admin/HeadAndFooter.jsx +++ b/front/components/admin/HeadAndFooter.jsx @@ -29,6 +29,10 @@ import { useRouter } from "next/router"; import { getSesion, logout } from "../../redux/actions/actionsUser"; import Swal from "sweetalert2"; import { useDispatch, useSelector } from "react-redux"; +import HomeIcon from "@mui/icons-material/Home"; +import { Flex } from "@chakra-ui/react"; + + // If loading a variable font, you don't need to specify the font weight const inter = Inter({ @@ -106,16 +110,19 @@ const HeadFooter = ({ children }) => { ProjUnity + + + + + Home + + + - - - Home - - diff --git a/front/pages/admin/gestionUsers.jsx b/front/pages/admin/gestionUsers.jsx index 78b1af3..76c7f44 100644 --- a/front/pages/admin/gestionUsers.jsx +++ b/front/pages/admin/gestionUsers.jsx @@ -18,7 +18,7 @@ import HeadFooter from "../../components/admin/HeadAndFooter"; import Swal from "sweetalert2"; import { useDispatch, useSelector } from "react-redux"; import { getUsers, deleteUser, restoreUser } from "../../redux/actions/actionsDashboard"; - +import Loader from "../../components/layout/loader"; // const userData = [ // { @@ -80,6 +80,9 @@ export default function GestionUsuarios() { const userData = useSelector((state) => state.userDashboard.dataUsers) +const loading = useSelector((state) => state.userDashboard.loading); + if (loading) return ; + const blockUser = (userId) => { // Mostrar una alerta de SweetAlert2 para confirmar el bloqueo del usuario @@ -98,7 +101,7 @@ const userData = useSelector((state) => state.userDashboard.dataUsers) }); }; - const restoreUser = (userId) => { + const restoreUsers = (userId) => { Swal.fire({ title: "Desbloquear usuario", @@ -143,7 +146,7 @@ const userData = useSelector((state) => state.userDashboard.dataUsers) {userData.map((user) => ( - + {user.id} {user.name} {user.email} @@ -153,6 +156,7 @@ const userData = useSelector((state) => state.userDashboard.dataUsers) colorScheme="red" size="sm" onClick={() => blockUser(user.id)} + disabled={user.status === 'Bloqueado'} > Bloquear @@ -165,7 +169,8 @@ const userData = useSelector((state) => state.userDashboard.dataUsers) colorScheme="blue" size="sm" ml="2" - onClick={() => restoreUser(user.id)} + onClick={() => restoreUsers(user.id)} + disabled={user.status !== 'Bloqueado'} > Desbloquear diff --git a/front/pages/admin/index.js b/front/pages/admin/index.js index 6edfa4e..85363b5 100644 --- a/front/pages/admin/index.js +++ b/front/pages/admin/index.js @@ -96,7 +96,7 @@ const AdminDashboard = () => { Dashboard de Administrador {/* Contenedor Flex para la tarjeta y el resumen */} - + {/* Tarjeta del Usuario */} {/* Tarjetas de los Estadisticos */} diff --git a/front/redux/reducers/dashboardReducer.js b/front/redux/reducers/dashboardReducer.js index 990b359..26a5928 100644 --- a/front/redux/reducers/dashboardReducer.js +++ b/front/redux/reducers/dashboardReducer.js @@ -19,7 +19,8 @@ const userDashboardReducer = (state = initialState, action) => { case GET_USERS: return { ...state, - dataUsers: action.payload + dataUsers: action.payload, + loading: false, } case DELETE_USER: return { diff --git a/front/redux/types.js b/front/redux/types.js index 9e5fea2..4a43558 100644 --- a/front/redux/types.js +++ b/front/redux/types.js @@ -41,6 +41,6 @@ export const RESTORE_USER = "RESTORE_USER" export const PAYMENT_RECORD = "PAYMENT_RECORD" //endpoint -// export const ENDPOINT = "http://localhost:3001/"; - export const ENDPOINT = "https://projunity-production.up.railway.app/"; +export const ENDPOINT = "http://localhost:3001/"; +// export const ENDPOINT = "https://projunity-production.up.railway.app/"; diff --git a/server/package-lock.json b/server/package-lock.json index 08ee94e..4a0c35b 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -21,6 +21,7 @@ "express-session": "^1.17.3", "fs-extra": "^11.1.1", "json-server": "^0.17.3", + "jsonwebtoken": "^9.0.2", "mercadopago": "^1.5.17", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", @@ -614,6 +615,11 @@ "node": ">=8" } }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -1137,6 +1143,14 @@ "safer-buffer": "^2.1.0" } }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -3145,6 +3159,46 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jsonwebtoken/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/jsonwebtoken/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -3173,6 +3227,25 @@ "node": ">=4.0" } }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, "node_modules/keyv": { "version": "4.5.3", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz", @@ -3244,11 +3317,46 @@ "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", diff --git a/server/package.json b/server/package.json index c0ebe33..6038b96 100644 --- a/server/package.json +++ b/server/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "Server Proyecto Final", "main": "index.js", -"scripts": { + "scripts": { "start": "node ./index.js", "dev": "nodemon -L" }, @@ -22,6 +22,7 @@ "express-session": "^1.17.3", "fs-extra": "^11.1.1", "json-server": "^0.17.3", + "jsonwebtoken": "^9.0.2", "mercadopago": "^1.5.17", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", diff --git a/server/src/db.js b/server/src/db.js index b9ea458..7af3953 100644 --- a/server/src/db.js +++ b/server/src/db.js @@ -12,15 +12,15 @@ const { -/* const sequelize = new Sequelize(`postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/projunity`, { + const sequelize = new Sequelize(`postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/projunity`, { logging: false, native: false, - }); */ + }); - const sequelize = new Sequelize(DEPLOY, { - logging: false, - native: false, - }); +// const sequelize = new Sequelize(DEPLOY, { +// logging: false, +// native: false, +// }); const basename = path.basename(__filename); From 7e7595efe179abf72ae767a9c30b93bdd12067a1 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Wed, 25 Oct 2023 18:31:24 -0300 Subject: [PATCH 10/60] Corrijo bug delete --- server/src/models/projects.js | 2 +- server/src/models/user.js | 2 +- server/src/services/Users.js | 10 +++++----- server/src/services/projects.js | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/src/models/projects.js b/server/src/models/projects.js index 3d9ecbd..63e3b62 100644 --- a/server/src/models/projects.js +++ b/server/src/models/projects.js @@ -12,7 +12,7 @@ sequelize.define('Projects', { type: DataTypes.TEXT, allowNull: false, }, - deleted: { + deletedAt: { type: DataTypes.BOOLEAN, defaultValue: false }, diff --git a/server/src/models/user.js b/server/src/models/user.js index ad2e130..71cd82f 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -36,7 +36,7 @@ module.exports = (sequelize) => { type: DataTypes.STRING, allowNull: true }, - deleted: { + deletedAt: { type: DataTypes.BOOLEAN, defaultValue: false }, diff --git a/server/src/services/Users.js b/server/src/services/Users.js index 2ae83d2..4d463ff 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -37,13 +37,13 @@ const userServices = { [Op.or]: [ {name: {[Op.iLike]: `${name}%`}}, ], - [Op.and]: [{deleted: 'false'}]}, + [Op.and]: [{active: 'true',deletedAt: 'false'}]}, attributes: ['id', 'name','email', 'image', 'twitterUser','emailUser','githubUser','linkedinUser','role'] }) return response } else { const response = await Users.findAll({ - where: {deleted: 'false'}, + where: {active: 'true', deletedAt: 'false'}, attributes: ['id','name','email', 'image', 'twitterUser','emailUser','githubUser', 'linkedinUser','role'] }) return response @@ -128,7 +128,7 @@ const userServices = { if (!user) { throw new Error('User not found'); } - await user.update({ deleted: true }); + await user.update({ deletedAt: true }); return { message: 'User deleted successfully' }; } catch (error) { throw new Error(error.message); @@ -138,7 +138,7 @@ const userServices = { getDeletedUsers: async function () { try { const deletedUsers = await Users.findAll({ - where: { deleted: true }, + where: { deletedAt: true }, attributes: ['id', 'name', 'email', 'image', 'twitterUser', 'emailUser', 'githubUser', 'linkedinUser', 'role'] }); @@ -154,7 +154,7 @@ const userServices = { if (!user) { throw new Error('User not found'); } - await user.update({ deleted: false }); + await user.update({ deletedAt: false }); return { message: 'User restored successfully' }; } catch (error) { throw new Error(error.message); diff --git a/server/src/services/projects.js b/server/src/services/projects.js index c7126b3..5dcdcc1 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -91,7 +91,7 @@ const ProjectServices = { condition.project = { ...condition.project, - deleted: false, + deletedAt: false, }; const projectsFilter = await Projects.findAll({ @@ -137,7 +137,7 @@ const ProjectServices = { getProjectsByID: async function (id) { try { const ProjectId = await Projects.findOne({ - where: { id: id, deleted: false }, + where: { id: id, deletedAt: false }, include: [ { model: Category, @@ -313,7 +313,7 @@ const ProjectServices = { if (!project) { throw new Error('Project not found'); } - await project.update({ deleted: true }); + await project.update({ deletedAt: true }); return { message: 'Project deleted successfully' }; } catch (error) { throw new Error(error.message); @@ -323,7 +323,7 @@ const ProjectServices = { getDeletedProjects: async function () { try { const deletedProjects = await Projects.findAll({ - where: { deleted: true }, + where: { deletedAt: true }, include: [ { model: Category, @@ -367,7 +367,7 @@ const ProjectServices = { if (!project) { throw new Error('Project not found'); } - await project.update({ deleted: false }); + await project.update({ deletedAt: false }); return { message: 'Project restored successfully' }; } catch (error) { throw new Error(error.message); From 6c527bf9f1f80093bdd08d083864556346e1d81d Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 00:35:33 -0300 Subject: [PATCH 11/60] Update mercadopago.js actualizo filtro payments y mercadopago --- server/src/controllers/mercadopago.js | 65 ++++++++++++++------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/server/src/controllers/mercadopago.js b/server/src/controllers/mercadopago.js index 62e4cc5..ee65c3e 100644 --- a/server/src/controllers/mercadopago.js +++ b/server/src/controllers/mercadopago.js @@ -11,7 +11,7 @@ const paymenntsControllers = { createPaymentPreference: async function(req, res ) { const { items, payer, concepto, status } = req.body; mercadopago.configure({ - access_token: MP_TOKEN + access_token: MP_TOKEN, }); const lastOrderNumber = await Payments.findAll({ @@ -51,7 +51,7 @@ const paymenntsControllers = { failure: `${DB_HOST}/pending`, }, notification_url: "https://3eb3-181-29-72-133.ngrok.io/webhook", - auto_return: "approved" + auto_return: "approved", }; try { const response = await mercadopago.preferences.create(preference); @@ -89,7 +89,7 @@ const paymenntsControllers = { ...itemsDb, { id: product, - name: productName.name, + title: productName.name, unit_price: paymentAmount, quantity: 1 } @@ -101,34 +101,37 @@ const paymenntsControllers = { } catch (error) { console.log(error); } - }, - // res.json({ - // id_mercadopago: global.id, - // init_point: response.body.init_point, - // items: response.body.items, - // back_urls: response.body.back_urls, - // total_amount:totalPrecio - // }); - - getOrdenId: async function(req, res){ - try { - const {id} = req.params - const payment = await paymentsServices.paymentId(id); - res.status(200).json(payment); - } catch (error) { - res.status(500).json(error.message); - } - }, - getAllPayment: async function(req, res){ - try { - const paymentsData = req.body; // <<< para que esta?? - const allPayments = await paymentsServices.allPayments(); - res.status(200).json(allPayments) - } catch (error) { - res.status(500).json(error.message) - } + }, + getOrdenId: async function(req, res){ + try { + const {id} = req.params + const payment = await paymentsServices.paymentId(id); + res.status(200).json(payment); + } catch (error) { + res.status(500).json(error.message); + } + }, + getAllPayment: async function(req, res){ + try { + const { desde, hasta } = req.query + const currentTime = new Date() + let fechaDesde = desde? desde.split('-') : []; + fechaDesde.length !== 3? + fechaDesde = new Date(currentTime.getFullYear(),currentTime.getMonth(),1,0,0,0) + : fechaDesde = new Date(parseInt(desde[0]),parseInt(desde[1])-1,parseInt(desde[2]),0,0,0); //<<--- si no esta definida la fecha desde, se define por defecto desde el primero del corriente mes + + let fechaHasta = hasta? hasta.split('-') : []; + fechaHasta.length !== 3? + fechaHasta = currentTime + : fechaHasta = new Date(parseInt(hasta[0]),parseInt(hasta[1])-1,parseInt(hasta[2]),0,0,0); + + const allPayments = await paymentsServices.allPayments({...req.query, desde: fechaDesde, hasta: fechaHasta}); + res.status(200).json(allPayments) + } catch (error) { + res.status(500).json(error.message) } - }; + } +}; -module.exports = paymenntsControllers \ No newline at end of file +module.exports = paymenntsControllers From 08a9b726c24f3f37c1b651b43749c87c2f338cfc Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 00:37:07 -0300 Subject: [PATCH 12/60] Update auth.js CORRIJO bug authentication github --- server/src/routes/auth.js | 49 ++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/server/src/routes/auth.js b/server/src/routes/auth.js index 07d1611..ca917a7 100644 --- a/server/src/routes/auth.js +++ b/server/src/routes/auth.js @@ -5,10 +5,13 @@ const GoogleStrategy = require('passport-google-oidc'); const GitHubStrategy = require('passport-github2').Strategy; const {Users, UsersTerceros} = require('../db'); const {Op} = require('sequelize') +const jwt = require('jsonwebtoken'); const pbkdf2 = require('pbkdf2'); const salt = process.env.SALT_KEY; +const JWT_KEY = process.env.JWT_KEY; + function encryptionPassword(password) { var key = pbkdf2.pbkdf2Sync( password, salt, 36000, 64, 'sha256' @@ -149,17 +152,45 @@ router.get('/oauth2/redirect', } }); -router.get('/login/github', passport.authenticate('github')); +router.get('/login/github',(req,res,next) => { + const {redirectTo} = req.query; + const state = JSON.stringify({redirectTo}); + const authenticator = passport.authenticate('github',{state, session: true}); + authenticator(req,res,next); + }, + (req,res,next) => { + next() + } +); router.get('/auth/github/callback', - passport.authenticate('github', { failureRedirect: '/login' }), - function(req, res) { - const {id, name, email, role, image, githubUser} = req.user - if(req.isAuthenticated) { - res.status(200).json({access: true, id, name, email, role, image, githubUser }) - } -}); + passport.authenticate('github', { failureRedirect: '/login' }), (req,res,next) => { + const token = jwt.sign({id: req.user.id}, JWT_KEY, {expiresIn: 60 * 60 * 24 * 1000}) + req.logIn(req.user, function(err) { + if (err) return next(err); ; + res.redirect(`http://localhost:3000?token=${token}`) + }); + }, +); +router.get('/profile', async (req, res) => { + + const token = req.headers['authorization']; + jwt.verify(token, process.env.JWT_KEY, function (err, data) { + if (err) { + res.status(401).send({ error: "NotAuthorized" }) + } else { + req.user = data + Users.findOne({ + where: {id: req.user.id}, + attributes: {exclude: ['password']}, + raw: true + }).then((user) => { + res.status(200).json(user) + }); + } + }) +}) router.get('/logout', function(req, res) { @@ -173,4 +204,4 @@ router.get('/logout', function(req, res) { } }); -module.exports = router \ No newline at end of file +module.exports = router From 2ee2d52bd0807de2716f4b95eb0821358676ae63 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 00:38:16 -0300 Subject: [PATCH 13/60] Update package.json agrego jsonwebtoken --- server/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/server/package.json b/server/package.json index 90adbeb..f2e5ed8 100644 --- a/server/package.json +++ b/server/package.json @@ -21,6 +21,7 @@ "express-session": "^1.17.3", "fs-extra": "^11.1.1", "json-server": "^0.17.3", + "jsonwebtoken": "^9.0.2", "mercadopago": "^1.5.17", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", From 4ca4d0192d7e7c383938515ca7638a883b1a0afd Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 00:43:19 -0300 Subject: [PATCH 14/60] Update index.js --- server/src/routes/index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/src/routes/index.js b/server/src/routes/index.js index 68a125d..f21a383 100644 --- a/server/src/routes/index.js +++ b/server/src/routes/index.js @@ -68,17 +68,14 @@ router router .route("/projects/:id") + .get(Controller.getProjectsID) .put(Controller.putProjects) - .delete( Controller.deleteProject) + .delete( Controller.deleteProject); router.put('/projects/restore/:id', Controller.restoreProject) router.get('/deleted-projects', Controller.getDeletedProjects); - -router.get('/projects/:id', Controller.getProjectsID); - - router.get("/categories", Controller.getCategories); router.get("/tags", Controller.getTags); From a4fae00f87004f5f891486b8d77e1f58f831b8f7 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 00:48:03 -0300 Subject: [PATCH 15/60] Update projectsUser.json corrijo bug wooComerce --- server/src/utils/projectsUser.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/utils/projectsUser.json b/server/src/utils/projectsUser.json index 5ff5663..6ee7b8c 100644 --- a/server/src/utils/projectsUser.json +++ b/server/src/utils/projectsUser.json @@ -1,6 +1,10 @@ { "data": [ + { + "ProjectId": 5, + "UserId": 1 + }, { "ProjectId": 1, "UserId": 5 @@ -66,4 +70,4 @@ "UserId": 5 } ] - } \ No newline at end of file + } From 4c478ac0159843e0c3df6dbc8aa3b80304e79fba Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 00:48:55 -0300 Subject: [PATCH 16/60] Update dashboard.js actualizo dashboard --- server/src/controllers/dashboard.js | 32 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/server/src/controllers/dashboard.js b/server/src/controllers/dashboard.js index e95756b..bf1b9a9 100644 --- a/server/src/controllers/dashboard.js +++ b/server/src/controllers/dashboard.js @@ -4,20 +4,32 @@ const dashBoardController = { getUserDashboard: async function (req,res) { try { const { id } = req.params - const { fecha } = req.query - let date = fecha? fecha.split('-') : [] - if (date.length !== 3) { - const currentTime = new Date() - date = new Date(currentTime.getFullYear(),currentTime.getMonth(),1,0,0,0) //<<--- si no esta definida la fecha desde, se define por defecto desde el primero del corriente mes + const { ventas, desde, hasta } = req.query + + const currentTime = new Date() + + let fechaDesde = desde? desde.split('-') : []; + fechaDesde.length !== 3? + fechaDesde = new Date(currentTime.getFullYear(),currentTime.getMonth(),1,0,0,0) + : fechaDesde = new Date(parseInt(desde[0]),parseInt(desde[1])-1,parseInt(desde[2]),0,0,0); //<<--- si no esta definida la fecha desde, se define por defecto desde el primero del corriente mes + + let fechaHasta = hasta? hasta.split('-') : []; + fechaHasta.length !== 3? + fechaHasta = currentTime + : fechaHasta = new Date(parseInt(hasta[0]),parseInt(hasta[1])-1,parseInt(hasta[2]),0,0,0); + let data; + if (ventas) { + data = await Services.userSalesDetail(parseInt(id), fechaDesde, fechaHasta) } else { - date = new Date(date[0],date[1]-1,date[2],0,0,0) + data = await Services.Dashboard(parseInt(id), fechaDesde); + } + if (data) { + res.status(200).json(data) } - const data = await Services.Dashboard(parseInt(id), date) - res.status(200).json(data) } catch (error) { res.status(500).json({message: error.message}) } - } + }, } -module.exports = dashBoardController \ No newline at end of file +module.exports = dashBoardController From a8ff16b17b65b6ae94949e9dcebf362e195e66ec Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 00:50:04 -0300 Subject: [PATCH 17/60] Update userDashboard.js actualizo dashboard con detalle de ventas por usuario por fecha --- server/src/services/userDashboard.js | 52 ++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/server/src/services/userDashboard.js b/server/src/services/userDashboard.js index 1991afb..224c2bb 100644 --- a/server/src/services/userDashboard.js +++ b/server/src/services/userDashboard.js @@ -1,6 +1,6 @@ const {Users, UserTypes, Projects, Payments, Ratings, ProjectUser} = require('../db'); const {Op, Sequelize} = require('sequelize'); -const {format} = require('date-fns') +const {format, addDays} = require('date-fns') const DashboardService = { Dashboard: async function (id, fecha) { @@ -134,7 +134,7 @@ const DashboardService = { return { totalProjects: totalProjects.count, activeSubscriptions: 75, - totalSales: `$${sales.valorizado - devoluciones.valorizado}`, + totalSales: sales.contador - devoluciones.contador, totalRevenue: `$${sales.valorizado - devoluciones.valorizado + donaciones.valorizado}`, averageSalesPerUser: await this.averageSales(id,fecha), activeProjects: count, @@ -161,6 +161,45 @@ const DashboardService = { return error } }, + userSalesDetail: async function (userId,desde,hasta) { + try { + const ProjectsIds = await Projects.findAll({ + include: { model: Users, where: {id: userId}, attributes: [] }, + attributes: ['id']}); + let userProducts = [] + for (let i in ProjectsIds) { userProducts.push(ProjectsIds[i].id)} + let dates = [] + //const hasta = new Date(fecha.getFullYear(),fecha.getMonth(),fecha.getDate()+30,0,0,0) + while (desde <= hasta) { + dates.push(desde) + desde = addDays(desde,1) + } + let ventas = [] + for (let i in dates) { + const data = await Payments.findAll({ + where: { + product: userProducts, + createdAt: dates[i], + status: 'completed', + concept: 'venta' + }, + attributes: [ + ['createdAt', 'fecha'], + [Sequelize.fn('count',Sequelize.col('product')),'proyectosVendidos'], + [Sequelize.fn('sum', Sequelize.col('paymentAmount')), 'ganancias'] + ], + group: ['fecha'], + raw: true + }); + data.length !== 0? + ventas.push(data[0]) + : ventas.push({fecha: dates[i], proyectosVendidos: 0, ganancias: 0}); + } + return ventas + } catch (error) { + return error + } + }, userDonations: async function (userId,fecha) { try { let donations = [] @@ -345,9 +384,10 @@ const DashboardService = { [Sequelize.fn('count',Sequelize.col('paymentAmount')), 'Count'] ], //group: ['product'], - where: {createdAt: { - [Op.between]: [fecha, hasta] - }} + where: { + createdAt: {[Op.between]: [fecha, hasta]}, + status: 'completed' + } }) return data } catch (error) { @@ -427,4 +467,4 @@ const DashboardService = { } } -module.exports = DashboardService \ No newline at end of file +module.exports = DashboardService From 05d9e9b840ffc604b61bcffafeb05e0a20bf68bc Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 00:59:18 -0300 Subject: [PATCH 18/60] jsonwebtoken en package log --- server/package-lock.json | 108 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/server/package-lock.json b/server/package-lock.json index d11877c..6d1c5b6 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -21,6 +21,7 @@ "express-session": "^1.17.3", "fs-extra": "^11.1.1", "json-server": "^0.17.3", + "jsonwebtoken": "^9.0.2", "mercadopago": "^1.5.17", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", @@ -615,6 +616,11 @@ "node": ">=8" } }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -1138,6 +1144,14 @@ "safer-buffer": "^2.1.0" } }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -3146,6 +3160,46 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jsonwebtoken/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/jsonwebtoken/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -3174,6 +3228,25 @@ "node": ">=4.0" } }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, "node_modules/keyv": { "version": "4.5.3", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz", @@ -3245,11 +3318,46 @@ "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", From 48aff3d9b61367e4093ae8d3a0cab711231db8ac Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 01:12:10 -0300 Subject: [PATCH 19/60] modificamos re-direct de git hub --- server/src/routes/auth.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/routes/auth.js b/server/src/routes/auth.js index ca917a7..98e16e7 100644 --- a/server/src/routes/auth.js +++ b/server/src/routes/auth.js @@ -12,6 +12,12 @@ const salt = process.env.SALT_KEY; const JWT_KEY = process.env.JWT_KEY; +const { + + GITHUB_CB_URL +} = process.env; + + function encryptionPassword(password) { var key = pbkdf2.pbkdf2Sync( password, salt, 36000, 64, 'sha256' @@ -168,7 +174,7 @@ router.get('/auth/github/callback', const token = jwt.sign({id: req.user.id}, JWT_KEY, {expiresIn: 60 * 60 * 24 * 1000}) req.logIn(req.user, function(err) { if (err) return next(err); ; - res.redirect(`http://localhost:3000?token=${token}`) + res.redirect(`https://proj-unity.vercel.app?token=${token}`) }); }, ); From bb7000e4ce3fbf1fdd3d194d3f7539fab5a8f329 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 01:28:45 -0300 Subject: [PATCH 20/60] Modifico github --- server/src/routes/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/routes/auth.js b/server/src/routes/auth.js index 98e16e7..fbe1cea 100644 --- a/server/src/routes/auth.js +++ b/server/src/routes/auth.js @@ -174,7 +174,7 @@ router.get('/auth/github/callback', const token = jwt.sign({id: req.user.id}, JWT_KEY, {expiresIn: 60 * 60 * 24 * 1000}) req.logIn(req.user, function(err) { if (err) return next(err); ; - res.redirect(`https://proj-unity.vercel.app?token=${token}`) + res.redirect(`https://projunity-production.up.railway.app?token=${token}`) }); }, ); From e6ad5f6c469b35ec5330ae8eb8fcc0f3f2b28694 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 01:34:07 -0300 Subject: [PATCH 21/60] Github --- server/src/routes/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/routes/auth.js b/server/src/routes/auth.js index fbe1cea..98e16e7 100644 --- a/server/src/routes/auth.js +++ b/server/src/routes/auth.js @@ -174,7 +174,7 @@ router.get('/auth/github/callback', const token = jwt.sign({id: req.user.id}, JWT_KEY, {expiresIn: 60 * 60 * 24 * 1000}) req.logIn(req.user, function(err) { if (err) return next(err); ; - res.redirect(`https://projunity-production.up.railway.app?token=${token}`) + res.redirect(`https://proj-unity.vercel.app?token=${token}`) }); }, ); From 0517376782351ef778df6eb21906bc9b4c7d536a Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 01:45:27 -0300 Subject: [PATCH 22/60] Console log req --- server/src/routes/auth.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/routes/auth.js b/server/src/routes/auth.js index 98e16e7..ba3a1d5 100644 --- a/server/src/routes/auth.js +++ b/server/src/routes/auth.js @@ -173,7 +173,8 @@ router.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/login' }), (req,res,next) => { const token = jwt.sign({id: req.user.id}, JWT_KEY, {expiresIn: 60 * 60 * 24 * 1000}) req.logIn(req.user, function(err) { - if (err) return next(err); ; + if (err) return next(err); + console.log('res redirect ', req); res.redirect(`https://proj-unity.vercel.app?token=${token}`) }); }, From 057c1bfc400cb21351f620067a222ad0b82d5df9 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 02:07:22 -0300 Subject: [PATCH 23/60] Comento nodemailer en user --- server/src/controllers/users.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index def5f3c..1d98ee1 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -14,11 +14,11 @@ const userControllers = { postUser: async function (req,res) { try { const Users = await Service.createUser(req.body) - const userMail = Users.email - const subject = "Usuario creado con éxito ✔"; - const text = `Hola ${Users.name}, te damos la bienvenida a PROJUNITY!.`; - const html = "Bievenido a la comunidad de PROJUNITY!" - sendEmail(userMail, subject, text, html) + // const userMail = Users.email + // const subject = "Usuario creado con éxito ✔"; + // const text = `Hola ${Users.name}, te damos la bienvenida a PROJUNITY!.`; + // const html = "Bievenido a la comunidad de PROJUNITY!" + // sendEmail(userMail, subject, text, html) res.status(200).json(Users) } catch (error) { From d7d92bfd428ff48e612da6213d89bcf1fab7aa41 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 02:30:55 -0300 Subject: [PATCH 24/60] Modifico mail de Alexis --- server/src/utils/users.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/utils/users.json b/server/src/utils/users.json index 4ada1e3..eddf5f6 100644 --- a/server/src/utils/users.json +++ b/server/src/utils/users.json @@ -17,7 +17,7 @@ }, { "name": "Alexis", - "email": "Alexis@projunity.com", + "email": "draco_alexis@hotmail.com", "password": "projunity", "image": "https://www.spotteron.net/images/icons/user60.png", "githubUser": "dracoalex84", From fdf62ebfb434866263f8df558b8eb0e7349f642c Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 02:36:10 -0300 Subject: [PATCH 25/60] Sube mail de usuario --- server/src/controllers/users.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index 1d98ee1..499e16c 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -14,13 +14,14 @@ const userControllers = { postUser: async function (req,res) { try { const Users = await Service.createUser(req.body) - // const userMail = Users.email - // const subject = "Usuario creado con éxito ✔"; - // const text = `Hola ${Users.name}, te damos la bienvenida a PROJUNITY!.`; - // const html = "Bievenido a la comunidad de PROJUNITY!" - // sendEmail(userMail, subject, text, html) + const userMail = Users.email + const subject = "Usuario creado con éxito ✔"; + const text = `Hola ${Users.name}, te damos la bienvenida a PROJUNITY!.`; + const html = "Bievenido a la comunidad de PROJUNITY!" + sendEmail(userMail, subject, text, html) res.status(200).json(Users) + console.log(Users); } catch (error) { res.status(500).json(error.message) } From 598244dca6474ce5ae0cac5442b03f461defb360 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 08:10:41 -0300 Subject: [PATCH 26/60] Update Users.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit añado varicable email a defaults de findorcreate usuarios --- server/src/services/Users.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/services/Users.js b/server/src/services/Users.js index 4d463ff..9d14686 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -67,6 +67,7 @@ const userServices = { where: {email: email}, defaults: { name, + email, password: encryptionPassword(password), image: uploadedImage.secure_url, twitterUser, @@ -163,4 +164,4 @@ const userServices = { } -module.exports = userServices \ No newline at end of file +module.exports = userServices From 8f2b09dbf41607c645fb2a31d046ece526711ae0 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 08:31:13 -0300 Subject: [PATCH 27/60] Update user.js agrego attributo paranoid true y quito columna deletedAt porque sequelize ya lo crea automatico --- server/src/models/user.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/src/models/user.js b/server/src/models/user.js index 71cd82f..d7b0c6f 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -36,10 +36,6 @@ module.exports = (sequelize) => { type: DataTypes.STRING, allowNull: true }, - deletedAt: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, emailUser: { type: DataTypes.STRING, unique: true, @@ -62,6 +58,7 @@ module.exports = (sequelize) => { }, { timestamps: true, + paranoid: true, freezeTableName: true }); -}; \ No newline at end of file +}; From 7911aa4528693463dd9078a3c9a2db975fd22c0f Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 08:47:16 -0300 Subject: [PATCH 28/60] Update payment.js agrego filtro fechas --- server/src/services/payment.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index 656d1d5..7aa82c3 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -6,17 +6,21 @@ const paymentsServices = { allPayments: async function(query) { try { - const { paymentId, status, paymentAmount, projects, UserId } = query; - const payments = await Payments.findAll({ - - - }); - const orderNumber = await Payments.findAll({ - attributes: [Sequelize.fn('max', Sequelize.col('orderNumber'))], + let { paymentId, status, paymentAmount, projects, UserId, desde, hasta } = query; + + const {count, rows} = await Payments.findAndCountAll({ + where: { + createdAt: {[Op.between]: [desde, hasta]}, + }, + order: [['createdAt', 'DESC']], raw: true - }) + }); + // const orderNumber = await Payments.findAll({ + // attributes: [Sequelize.fn('max', Sequelize.col('orderNumber'))], + // raw: true + // }) - return payments; + return rows; } catch (error) { //console.error('Error al obtener payments:', error); @@ -36,4 +40,4 @@ const paymentsServices = { }, // el create payment de mercado pago esta realizado desde /controllers/mercadopago.js }; -module.exports = paymentsServices; \ No newline at end of file +module.exports = paymentsServices; From 51e7ecafdc02820059d67068b09bd1da2acc5c41 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 08:52:03 -0300 Subject: [PATCH 29/60] Update package.json agrego paquete date-fns para formatear fechas --- front/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/front/package.json b/front/package.json index 11fbf7d..974d78d 100644 --- a/front/package.json +++ b/front/package.json @@ -21,6 +21,7 @@ "@nextui-org/react": "^2.1.13", "@react-email/link": "0.0.5", "axios": "^1.5.1", + "date-fns": "^2.30.0", "formik": "^2.4.5", "framer-motion": "^10.16.4", "jspdf": "^2.5.1", From 174d278118815dd6be57b2a57447075848203dab Mon Sep 17 00:00:00 2001 From: jesib03 Date: Thu, 26 Oct 2023 09:55:50 -0300 Subject: [PATCH 30/60] maaaas --- front/components/layout/SearchBar.jsx | 2 +- front/redux/types.js | 4 ++-- server/index.js | 34 +++++++++++++-------------- server/src/db.js | 18 +++++++------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/front/components/layout/SearchBar.jsx b/front/components/layout/SearchBar.jsx index 187a9c8..9e7da5f 100644 --- a/front/components/layout/SearchBar.jsx +++ b/front/components/layout/SearchBar.jsx @@ -32,7 +32,7 @@ function SearchBar() {
{ server.listen(PORT, async () => { - await UserTypes.bulkCreate(userTypes); - for (let i in users) { - await createUser(users[i]); - } - await Projects.bulkCreate(projects.data); - await Category.bulkCreate(categories); - await Comments.bulkCreate(comments); - await ProjectComments.bulkCreate(commentsProject); - await Ratings.bulkCreate(ratings); - await ProjectRatings.bulkCreate(projectsRatings); - await Payments.bulkCreate(payments); - await Tags.bulkCreate(tags); - await Ratings.bulkCreate(ratings); - await ProjectUser.bulkCreate(projectUser.data); - await ProjectCategory.bulkCreate(projectCategory); - await ProjectTags.bulkCreate(projectTags); + // await UserTypes.bulkCreate(userTypes); + // for (let i in users) { + // await createUser(users[i]); + // } + // await Projects.bulkCreate(projects.data); + // await Category.bulkCreate(categories); + // await Comments.bulkCreate(comments); + // await ProjectComments.bulkCreate(commentsProject); + // await Ratings.bulkCreate(ratings); + // await ProjectRatings.bulkCreate(projectsRatings); + // await Payments.bulkCreate(payments); + // await Tags.bulkCreate(tags); + // await Ratings.bulkCreate(ratings); + // await ProjectUser.bulkCreate(projectUser.data); + // await ProjectCategory.bulkCreate(projectCategory); + // await ProjectTags.bulkCreate(projectTags); console.log(`Server listening on port ${PORT}`); }); diff --git a/server/src/db.js b/server/src/db.js index 7af3953..51dc766 100644 --- a/server/src/db.js +++ b/server/src/db.js @@ -12,15 +12,15 @@ const { - const sequelize = new Sequelize(`postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/projunity`, { - logging: false, - native: false, - }); - -// const sequelize = new Sequelize(DEPLOY, { -// logging: false, -// native: false, -// }); +// const sequelize = new Sequelize(`postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/projunity`, { +// logging: false, +// native: false, +// }); + + const sequelize = new Sequelize(DEPLOY, { + logging: false, + native: false, + }); const basename = path.basename(__filename); From 8eaa86fcac72f3a25bd51595451fa8e4464501aa Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 10:02:01 -0300 Subject: [PATCH 31/60] Update payment.js formateo payment con nombres de pruducto y comprador --- server/src/services/payment.js | 49 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index 7aa82c3..dc990a2 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -1,6 +1,7 @@ -const { Projects, Payments} = require('../db.js'); // Importa tus modelos de órdenes +const { Projects, Payments, Users} = require('../db.js'); // Importa tus modelos de órdenes const { Op, Sequelize } = require('sequelize'); -const Controllers = require("./index.js") +const {format} = require('date-fns'); +const Controllers = require("./index.js"); const paymentsServices = { @@ -12,15 +13,34 @@ const paymentsServices = { where: { createdAt: {[Op.between]: [desde, hasta]}, }, + include: { + model: Users, + attributes: ['name'] + }, + attributes: ['id','paymentId','paymentAmount','status','concept','orderNumber','createdAt','product'], order: [['createdAt', 'DESC']], raw: true }); - // const orderNumber = await Payments.findAll({ - // attributes: [Sequelize.fn('max', Sequelize.col('orderNumber'))], - // raw: true - // }) - - return rows; + const projectsName = await Projects.findAll({attributes: ['id','name']}) + + let payments = [] + for (let i in rows) { + payments = [ + ...payments, + { + id: rows[i].id, + paymentId: rows[i].paymentId, + paymentAmount: rows[i].paymentAmount, + status: rows[i].status, + concept: rows[i].concept, + orderNumber: rows[i].orderNumber, + product: projectsName.filter((x) => x.id === rows[i].product)[0].name, + buyer: rows[i]['User.name'], + createdAt: format(rows[i].createdAt, 'yyyy-MM-dd hh:mm') + } + ] + } + return payments; } catch (error) { //console.error('Error al obtener payments:', error); @@ -28,16 +48,3 @@ const paymentsServices = { } }, - paymentId: async function(id) { - try { - const order = await Payments.findByPk(id); - return order; - } catch (error) { - - console.error('Error al obtener la orden por ID:', error); - throw error; - } - }, // el create payment de mercado pago esta realizado desde /controllers/mercadopago.js -}; - -module.exports = paymentsServices; From 27907b6132a3d5bf17ba766b9d618228927f084f Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 10:16:05 -0300 Subject: [PATCH 32/60] Update payment.js remplazo productid y buyerid por los nombres de cada uno --- server/src/services/payment.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index dc990a2..87d074a 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -48,3 +48,16 @@ const paymentsServices = { } }, + paymentId: async function(id) { + try { + const order = await Payments.findByPk(id); + return order; + } catch (error) { + + console.error('Error al obtener la orden por ID:', error); + throw error; + } + }, // el create payment de mercado pago esta realizado desde /controllers/mercadopago.js +}; + +module.exports = paymentsServices; From 07b62c9eebde4340168f028a620a764c1d01c7b3 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 11:21:57 -0300 Subject: [PATCH 33/60] Update Users.js corrijo service paranoid --- server/src/services/Users.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/src/services/Users.js b/server/src/services/Users.js index 9d14686..f604309 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -32,19 +32,19 @@ const userServices = { try{ if (name) { const response = await Users.findAll({ - where: + where: { {name: { [Op.iLike]: `%${name}%`}, [Op.or]: [ {name: {[Op.iLike]: `${name}%`}}, - ], - [Op.and]: [{active: 'true',deletedAt: 'false'}]}, - attributes: ['id', 'name','email', 'image', 'twitterUser','emailUser','githubUser','linkedinUser','role'] + ]}, + attributes: {exclude: ['password']}, + paranoid: true }) return response } else { const response = await Users.findAll({ - where: {active: 'true', deletedAt: 'false'}, - attributes: ['id','name','email', 'image', 'twitterUser','emailUser','githubUser', 'linkedinUser','role'] + attributes: {exclude: ['password']}, + paranoid: true }) return response } @@ -129,7 +129,7 @@ const userServices = { if (!user) { throw new Error('User not found'); } - await user.update({ deletedAt: true }); + await user.destroy(); return { message: 'User deleted successfully' }; } catch (error) { throw new Error(error.message); @@ -139,8 +139,8 @@ const userServices = { getDeletedUsers: async function () { try { const deletedUsers = await Users.findAll({ - where: { deletedAt: true }, - attributes: ['id', 'name', 'email', 'image', 'twitterUser', 'emailUser', 'githubUser', 'linkedinUser', 'role'] + paranoid: false, + attributes: {exclude: ['password']} }); return deletedUsers; @@ -151,11 +151,11 @@ const userServices = { restoreUsers: async function(userId) { try { - const user = await Users.findByPk(userId); + const user = await Users.findOne({where: {id: userId}}, paranoid: false); if (!user) { throw new Error('User not found'); } - await user.update({ deletedAt: false }); + await user.restore(); return { message: 'User restored successfully' }; } catch (error) { throw new Error(error.message); From 833203dbe68a75820c2a5a4e69af58a6ff72df15 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 11:26:48 -0300 Subject: [PATCH 34/60] Update Users.js --- server/src/services/Users.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/services/Users.js b/server/src/services/Users.js index f604309..b5c3392 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -33,10 +33,9 @@ const userServices = { if (name) { const response = await Users.findAll({ where: { - {name: { [Op.iLike]: `%${name}%`}, - [Op.or]: [ - {name: {[Op.iLike]: `${name}%`}}, - ]}, + name: { [Op.iLike]: `%${name}%` }, + [Op.or]: [{ name: { [Op.iLike]: `${name}%` } }], + }, attributes: {exclude: ['password']}, paranoid: true }) From 079f3816d61f49d317f632b4bf25ede5072355a6 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 11:29:38 -0300 Subject: [PATCH 35/60] Update Users.js --- server/src/services/Users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/services/Users.js b/server/src/services/Users.js index b5c3392..29c4c32 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -150,7 +150,7 @@ const userServices = { restoreUsers: async function(userId) { try { - const user = await Users.findOne({where: {id: userId}}, paranoid: false); + const user = await Users.findOne({where: {id: userId}, paranoid: false}); if (!user) { throw new Error('User not found'); } From a7132baa1514eacd0eb09e45aa23355e2ce372e9 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 12:34:48 -0300 Subject: [PATCH 36/60] Update Users.js corrijo bugs usuarios deleted y manejo de paranoid --- server/src/services/Users.js | 47 +++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/server/src/services/Users.js b/server/src/services/Users.js index 29c4c32..df3b8a1 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -28,29 +28,38 @@ function encryptionPassword(password) { const userServices = { - allUsers: async function (name) { + allUsers: async function (queryParams) { try{ - if (name) { - const response = await Users.findAll({ - where: { - name: { [Op.iLike]: `%${name}%` }, - [Op.or]: [{ name: { [Op.iLike]: `${name}%` } }], - }, - attributes: {exclude: ['password']}, - paranoid: true - }) - return response - } else { - const response = await Users.findAll({ - attributes: {exclude: ['password']}, - paranoid: true - }) - return response - } + const { name, deleted } = queryParams + + const response = await Users.findAll({ + where: name? { + name: { [Op.iLike]: `%${name}%` }, + [Op.or]: [{ name: { [Op.iLike]: `${name}%` } }], + } : null, + paranoid: deleted? false : true, + attributes: {exclude: ['password']}, + }) + return response } catch (error) { return error } }, + userById: async function(id) { + try { + const userId = await Users.findOne({ + where: {id: id}, + attributes: {exclude: ['password']} + }); + if (userId) { + return userId + } else { + return 'User not Found' + } + } catch (error) { + return error + } + }, createUser: async function (userData) { try { const { name, email, password, image, twitterUser, emailUser, githubUser, linkedinUser, role} = userData @@ -141,7 +150,7 @@ const userServices = { paranoid: false, attributes: {exclude: ['password']} }); - + return deletedUsers; } catch (error) { throw new Error(error.message); From 0f5d1022f4ccff1ee70f4853fd96aceb80599fd1 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 12:36:18 -0300 Subject: [PATCH 37/60] Update users.js update controllers usuarios --- server/src/controllers/users.js | 48 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index 499e16c..42f92a6 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -1,27 +1,35 @@ const Service = require('../services').userServices; -const { sendEmail } = require('./mailer'); const userControllers = { getUsers: async function (req,res) { try { - const { name } = req.query - const Users = await Service.allUsers(name) + const { name, deleted } = req.query + const Users = await Service.allUsers({name, deleted}) res.status(200).json(Users) } catch (error) { res.status(500).json(error.message) } }, + getUserById: async function(req,res) { + try { + const {id} = req.params; + const User = await Service.userById(id) + if (User) { + res.status(200).json(User) + } + } catch (error) { + res.status(500).json(error.message) + } + }, postUser: async function (req,res) { try { const Users = await Service.createUser(req.body) - const userMail = Users.email - const subject = "Usuario creado con éxito ✔"; - const text = `Hola ${Users.name}, te damos la bienvenida a PROJUNITY!.`; - const html = "Bievenido a la comunidad de PROJUNITY!" - sendEmail(userMail, subject, text, html) - - res.status(200).json(Users) - console.log(Users); + if (Users.id) { + res.status(201).json(Users); + } else { + res.status(400).json({ type: "error", response: "Algo falló" }); + } + console.log(Users) } catch (error) { res.status(500).json(error.message) } @@ -32,27 +40,17 @@ const userControllers = { const userId = req.params.id; const result = await Service.deleteUserbyId(userId); - + res.status(200).json(result); } catch (error) { res.status(500).json(error.message); } }, - - getDeletedUsers: async function (req, res) { - try { - const deletedUsers = await Service.getDeletedUsers(); - res.status(200).json(deletedUsers); - } catch (error) { - res.status(500).json(error.message); - } - }, - restoreUser : async function (req, res) { try{ - const userId = req.params.id; - const result = await Service.restoreUsers(userId); + const {id} = req.params; + const result = await Service.restoreUsers(id); res.status(200).json(result); }catch(error){ res.status(500).json(error.message); @@ -60,4 +58,4 @@ const userControllers = { } } -module.exports = userControllers \ No newline at end of file +module.exports = userControllers From 8c4e5fa28e42fdd45066a9063139e53089489a36 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 12:37:25 -0300 Subject: [PATCH 38/60] Update index.js update rutas usuarios restore --- server/src/routes/index.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/server/src/routes/index.js b/server/src/routes/index.js index f21a383..5108045 100644 --- a/server/src/routes/index.js +++ b/server/src/routes/index.js @@ -33,22 +33,20 @@ function isAuthorized(req, res, next) { router.get("/", isAuthenticated); +router.route('/users/:id') + .get(Controller.getUserById) + .delete(isAuthenticated, isAuthorized, Controller.deleteUser); -router.delete('/users/:id', Controller.deleteUser) -router.put('/users/restore/:id',Controller.restoreUser) +router.put('/users/restore/:id',isAuthenticated, isAuthorized, Controller.restoreUser); -router.get('/users/:id/dashboard', Controller.getUserDashboard) - -router.get('/deleted-users', Controller.getDeletedUsers); - +router.get('/users/:id/dashboard', Controller.getUserDashboard); router.post("/sign-up", Controller.postUser); router.route('/users') .get(Controller.getUsers); -/* router.post('/sign-up', Controller.postUser); */ router.get( "/usertypes", @@ -65,7 +63,6 @@ router .get(Controller.getProjects) .post(Controller.createNewProject); - router .route("/projects/:id") .get(Controller.getProjectsID) @@ -73,8 +70,6 @@ router .delete( Controller.deleteProject); router.put('/projects/restore/:id', Controller.restoreProject) -router.get('/deleted-projects', Controller.getDeletedProjects); - router.get("/categories", Controller.getCategories); router.get("/tags", Controller.getTags); @@ -103,6 +98,3 @@ router module.exports = router; - - - From 36aeb98f1884d218f05a970c58a2bc193fa0d057 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 14:16:47 -0300 Subject: [PATCH 39/60] Update userDashboard.js --- server/src/services/userDashboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/services/userDashboard.js b/server/src/services/userDashboard.js index 224c2bb..f7654df 100644 --- a/server/src/services/userDashboard.js +++ b/server/src/services/userDashboard.js @@ -192,8 +192,8 @@ const DashboardService = { raw: true }); data.length !== 0? - ventas.push(data[0]) - : ventas.push({fecha: dates[i], proyectosVendidos: 0, ganancias: 0}); + ventas.push({...data[0], fecha: format(data[0].fecha, 'yyyy-MM-dd')}) + : ventas.push({fecha: format(dates[i], 'yyyy-MM-dd'), proyectosVendidos: 0, ganancias: 0}); } return ventas } catch (error) { From 353ec7eb185b504db8f08e0476b3605ab8905244 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 14:35:03 -0300 Subject: [PATCH 40/60] Update Users.js corrijo error creacion nuevo usuario --- server/src/services/Users.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/services/Users.js b/server/src/services/Users.js index df3b8a1..5a94da4 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -68,16 +68,17 @@ const userServices = { throw Error(`Missing some data`) } else { - - const uploadedImage = await cloudinary.uploader.upload(image); - + let uploadedImage; + if (image) { + uploadedImage = await cloudinary.uploader.upload(image); + } const [newUser, created] = await Users.findOrCreate({ where: {email: email}, defaults: { name, email, password: encryptionPassword(password), - image: uploadedImage.secure_url, + image: uploadedImage? uploadedImage.secure_url : null, twitterUser, emailUser, githubUser, From d76e9e1099574f6e9097a0cfa175cc93ef3a6ada Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 20:43:05 -0300 Subject: [PATCH 41/60] Update projects.js --- server/src/services/projects.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index 5dcdcc1..3363d82 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -19,7 +19,7 @@ cloudinary.config({ const ProjectServices = { allProjects: async function (queryParams) { try { - const { name, category, tag, price, rating, username, id } = queryParams; + const { name, category, tag, price, rating, username, id, deleted } = queryParams; let condition = {}; id ? (condition = { @@ -127,6 +127,7 @@ const ProjectServices = { } ], where: condition.project, + paranoid: deleted? false : true }); return projectsFilter; } catch (error) { @@ -377,4 +378,4 @@ const ProjectServices = { }; -module.exports = ProjectServices; \ No newline at end of file +module.exports = ProjectServices; From 7e8bf35a0ce9e68e39273d9cab2591b8a367e237 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 21:49:41 -0300 Subject: [PATCH 42/60] Update projects.js cambio service proejct delete de update a destroy/restore --- server/src/services/projects.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index 3363d82..9d94190 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -314,7 +314,7 @@ const ProjectServices = { if (!project) { throw new Error('Project not found'); } - await project.update({ deletedAt: true }); + await project.destroy(); return { message: 'Project deleted successfully' }; } catch (error) { throw new Error(error.message); @@ -364,11 +364,11 @@ const ProjectServices = { restoreProjects: async function(projectId) { try { - const project = await Projects.findByPk(projectId); + const project = await Projects.findByPk(projectId, {paranoid: false}); if (!project) { throw new Error('Project not found'); } - await project.update({ deletedAt: false }); + await project.restore(); return { message: 'Project restored successfully' }; } catch (error) { throw new Error(error.message); From c490599f513dfcca5d43d83960b3dca3fcc1ba21 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 21:57:02 -0300 Subject: [PATCH 43/60] Update projects.js agrego paranoid true y quito columna deletedAt booleana --- server/src/models/projects.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/src/models/projects.js b/server/src/models/projects.js index 63e3b62..f86192b 100644 --- a/server/src/models/projects.js +++ b/server/src/models/projects.js @@ -12,10 +12,6 @@ sequelize.define('Projects', { type: DataTypes.TEXT, allowNull: false, }, - deletedAt: { - type: DataTypes.BOOLEAN, - defaultValue: false - }, price: { type: DataTypes.DECIMAL(11,2), allowNull: false, @@ -53,6 +49,7 @@ sequelize.define('Projects', { }, { timestamps: true, + paranoid: true, freezeTableName: true } ); From 3b8ae8d724fb469873a651caea0bccb461d1a073 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 22:17:20 -0300 Subject: [PATCH 44/60] Corrijo bug --- server/src/services/projects.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index 9d94190..acda3a1 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -91,7 +91,6 @@ const ProjectServices = { condition.project = { ...condition.project, - deletedAt: false, }; const projectsFilter = await Projects.findAll({ @@ -138,7 +137,7 @@ const ProjectServices = { getProjectsByID: async function (id) { try { const ProjectId = await Projects.findOne({ - where: { id: id, deletedAt: false }, + where: { id: id}, include: [ { model: Category, @@ -324,7 +323,7 @@ const ProjectServices = { getDeletedProjects: async function () { try { const deletedProjects = await Projects.findAll({ - where: { deletedAt: true }, + where: { paranoid: false }, include: [ { model: Category, From 9e34c3f14170f080c8c7a7f0d9d6d2f1dbd0b9b2 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:03:17 -0300 Subject: [PATCH 45/60] Update mercadopago.js --- server/src/controllers/mercadopago.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/src/controllers/mercadopago.js b/server/src/controllers/mercadopago.js index ee65c3e..100d6f6 100644 --- a/server/src/controllers/mercadopago.js +++ b/server/src/controllers/mercadopago.js @@ -9,7 +9,7 @@ const paymenntsControllers = { // Función para crear una preferencia de pago en MercadoPago createPaymentPreference: async function(req, res ) { - const { items, payer, concepto, status } = req.body; + mercadopago.configure({ access_token: MP_TOKEN, }); @@ -20,27 +20,28 @@ const paymenntsControllers = { }) const orderNumber = lastOrderNumber[0].max+1 - + let items = req.body for (let i in items) { const createOrder = await Payments.create({ paymentAmount: items[i].unit_price, orderNumber: orderNumber, product: items[i].id, - buyer: payer, - concept: concepto? concepto : 'venta', //venta, donacion o devolucion - status: status? status : 'processing', + buyer: items[i].buyer, + concept: items[i].concept? items[i].concept : 'venta', //venta, donacion o devolucion + status: items[i].status? items[i].status : 'processing', }) } - const totalPrecio = items.reduce((acumulador, producto) => + const totalPrecio = req.body.reduce((acumulador, producto) => acumulador + parseFloat(producto.unit_price), 0); + const preference = { items, total_amount: totalPrecio, external_reference : `${orderNumber}`, payer: await Users.findOne({ - where: {id: payer}, + where: {id: items[0].buyer}, attributes: ['name', 'email'], raw: true }), From a129ba678b51ad23d836c8f02ab5a3f416015214 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:12:25 -0300 Subject: [PATCH 46/60] Update mercadopago.js --- server/src/controllers/mercadopago.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/controllers/mercadopago.js b/server/src/controllers/mercadopago.js index 100d6f6..417dba2 100644 --- a/server/src/controllers/mercadopago.js +++ b/server/src/controllers/mercadopago.js @@ -47,7 +47,7 @@ const paymenntsControllers = { }), back_urls: { - success: "http://localhost:3001/createPayment/succes", + success: "https://proj-unity.vercel.app/createPayment/succes", pending: `${DB_HOST}/error`, failure: `${DB_HOST}/pending`, }, From 49c6b5a04ef098547faa3906785d136911b2362c Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:20:40 -0300 Subject: [PATCH 47/60] Update index.js --- server/src/routes/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/routes/index.js b/server/src/routes/index.js index 5108045..b2372a4 100644 --- a/server/src/routes/index.js +++ b/server/src/routes/index.js @@ -93,7 +93,8 @@ router.get("/payment",Controller.getAllPayment) router .route("/createPayment/succes") .get((req, res)=> { - res.send("PAGO REALIZADO CON EXITO") + res.redirect('https://proj-unity.vercel.app/') + //res.send('PAGO REALIZADO CON EXITO') }) From bf1dd8732b17e67f79899f526a7f5c7af4a6f9fb Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:23:39 -0300 Subject: [PATCH 48/60] Update index.js --- server/src/routes/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/routes/index.js b/server/src/routes/index.js index b2372a4..ae5fe2b 100644 --- a/server/src/routes/index.js +++ b/server/src/routes/index.js @@ -91,7 +91,7 @@ router router.get("/payment/:id", Controller.getOrdenId); router.get("/payment",Controller.getAllPayment) router -.route("/createPayment/succes") +.route("/payment/succes") .get((req, res)=> { res.redirect('https://proj-unity.vercel.app/') //res.send('PAGO REALIZADO CON EXITO') From ce796188ead0ef74a9286fa0366384d66e1bae45 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:24:07 -0300 Subject: [PATCH 49/60] Update mercadopago.js --- server/src/controllers/mercadopago.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/controllers/mercadopago.js b/server/src/controllers/mercadopago.js index 417dba2..661ad67 100644 --- a/server/src/controllers/mercadopago.js +++ b/server/src/controllers/mercadopago.js @@ -47,7 +47,7 @@ const paymenntsControllers = { }), back_urls: { - success: "https://proj-unity.vercel.app/createPayment/succes", + success: "https://proj-unity.vercel.app", pending: `${DB_HOST}/error`, failure: `${DB_HOST}/pending`, }, From 608a0af46d8c30c8ee315182bd4679fd943d6f5b Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:41:52 -0300 Subject: [PATCH 50/60] Update payment.js --- server/src/services/payment.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index 87d074a..2190f29 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -7,8 +7,9 @@ const paymentsServices = { allPayments: async function(query) { try { - let { paymentId, status, paymentAmount, projects, UserId, desde, hasta } = query; - + let { paymentId, status, paymentAmount, projects, UserId, /* desde, hasta */} = query; + let desde = new date() + let hasta = new date(2023,10,10,0,0,0) const {count, rows} = await Payments.findAndCountAll({ where: { createdAt: {[Op.between]: [desde, hasta]}, From 6552da3527647edd5222fc166ce1fdb19d978f14 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:42:39 -0300 Subject: [PATCH 51/60] Update payment.js --- server/src/services/payment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index 2190f29..18d5aee 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -8,8 +8,8 @@ const paymentsServices = { allPayments: async function(query) { try { let { paymentId, status, paymentAmount, projects, UserId, /* desde, hasta */} = query; - let desde = new date() - let hasta = new date(2023,10,10,0,0,0) + let hasta = new date() + let desde = new date(2023,10,10,0,0,0) const {count, rows} = await Payments.findAndCountAll({ where: { createdAt: {[Op.between]: [desde, hasta]}, From b49f9dc206e1772a728c89cb276a5f512fd39cbd Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:43:33 -0300 Subject: [PATCH 52/60] Update payment.js --- server/src/services/payment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index 18d5aee..6757063 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -8,8 +8,8 @@ const paymentsServices = { allPayments: async function(query) { try { let { paymentId, status, paymentAmount, projects, UserId, /* desde, hasta */} = query; - let hasta = new date() - let desde = new date(2023,10,10,0,0,0) + let hasta = new Date() + let desde = new Date(2023,10,10,0,0,0) const {count, rows} = await Payments.findAndCountAll({ where: { createdAt: {[Op.between]: [desde, hasta]}, From f39d7a97333582ba508729e17a819cabc83569a2 Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:49:13 -0300 Subject: [PATCH 53/60] Update payment.js --- server/src/services/payment.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index 6757063..d33e9e5 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -7,9 +7,8 @@ const paymentsServices = { allPayments: async function(query) { try { - let { paymentId, status, paymentAmount, projects, UserId, /* desde, hasta */} = query; - let hasta = new Date() - let desde = new Date(2023,10,10,0,0,0) + let { paymentId, status, paymentAmount, projects, UserId, desde, hasta } = query; + const {count, rows} = await Payments.findAndCountAll({ where: { createdAt: {[Op.between]: [desde, hasta]}, @@ -36,7 +35,7 @@ const paymentsServices = { concept: rows[i].concept, orderNumber: rows[i].orderNumber, product: projectsName.filter((x) => x.id === rows[i].product)[0].name, - buyer: rows[i]['User.name'], + buyer: rows[i]?['User.name']?, createdAt: format(rows[i].createdAt, 'yyyy-MM-dd hh:mm') } ] From a6f3dc10bb3dcd8e8d6251b708061619be3d3e2a Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 23:51:24 -0300 Subject: [PATCH 54/60] Update payment.js --- server/src/services/payment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/services/payment.js b/server/src/services/payment.js index d33e9e5..d2dabf6 100644 --- a/server/src/services/payment.js +++ b/server/src/services/payment.js @@ -35,7 +35,7 @@ const paymentsServices = { concept: rows[i].concept, orderNumber: rows[i].orderNumber, product: projectsName.filter((x) => x.id === rows[i].product)[0].name, - buyer: rows[i]?['User.name']?, + buyer: rows[i]['User.name']? rows[i]['User.name'] : 'undefined', createdAt: format(rows[i].createdAt, 'yyyy-MM-dd hh:mm') } ] From 98682af7efb7fcdbda7ff4064bdbe61572cccadf Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Thu, 26 Oct 2023 23:57:55 -0300 Subject: [PATCH 55/60] =?UTF-8?q?Mail=20confirmaci=C3=B3n=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controllers/users.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index 42f92a6..a4bf16c 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -25,6 +25,23 @@ const userControllers = { try { const Users = await Service.createUser(req.body) if (Users.id) { + + const subject = "Usuario creado con éxito ✔ 😉"; + const text = `Querido ${Users.name} Tu proyecto se ha creado con éxito. Felicitaciones y gracias por hacer de nuestra comunidad un lugar mejor! ` + const html = `

+ Querido ${Users.name} +

+ +

Muchas gracias por formar parte de nuestra comunidad. Esperamos que disfrutes de tu experiencia en nuestro sitio.

+

Te recordamos que podés ingresar a tu cuenta con tu email y la contraseña que elegiste al registrarte.

+

¡Te esperamos pronto!

+

Saludos,

+
+

El equipo de ProJunity

+

@2023 ProJunity. Todos los derechos reservados.

+ ` + sendEmail(userMail, subject, text, html) + res.status(201).json(Users); } else { res.status(400).json({ type: "error", response: "Algo falló" }); From 7fffefa2c8c4ffc23768ba47abd3a757ee1243ab Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Fri, 27 Oct 2023 00:21:26 -0300 Subject: [PATCH 56/60] Envio mail de usuario --- server/index.js | 34 ++++++++++++++++----------------- server/src/controllers/users.js | 2 ++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/server/index.js b/server/index.js index b2d4470..c5c0d22 100644 --- a/server/index.js +++ b/server/index.js @@ -34,25 +34,25 @@ const { } = require("./src/db"); const { createUser } = require("./src/services/Users"); conn - .sync({ force: true }) + .sync({ force: false }) .then(() => { server.listen(PORT, async () => { - await UserTypes.bulkCreate(userTypes); - for (let i in users) { - await createUser(users[i]); - } - await Projects.bulkCreate(projects.data); - await Category.bulkCreate(categories); - await Comments.bulkCreate(comments); - await ProjectComments.bulkCreate(commentsProject); - await Ratings.bulkCreate(ratings); - await ProjectRatings.bulkCreate(projectsRatings); - await Payments.bulkCreate(payments); - await Tags.bulkCreate(tags); - await Ratings.bulkCreate(ratings); - await ProjectUser.bulkCreate(projectUser.data); - await ProjectCategory.bulkCreate(projectCategory); - await ProjectTags.bulkCreate(projectTags); + // await UserTypes.bulkCreate(userTypes); + // for (let i in users) { + // await createUser(users[i]); + // } + // await Projects.bulkCreate(projects.data); + // await Category.bulkCreate(categories); + // await Comments.bulkCreate(comments); + // await ProjectComments.bulkCreate(commentsProject); + // await Ratings.bulkCreate(ratings); + // await ProjectRatings.bulkCreate(projectsRatings); + // await Payments.bulkCreate(payments); + // await Tags.bulkCreate(tags); + // await Ratings.bulkCreate(ratings); + // await ProjectUser.bulkCreate(projectUser.data); + // await ProjectCategory.bulkCreate(projectCategory); + // await ProjectTags.bulkCreate(projectTags); console.log(`Server listening on port ${PORT}`); }); diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index a4bf16c..4fdf686 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -1,4 +1,5 @@ const Service = require('../services').userServices; +const {sendEmail} = require("./mailer"); const userControllers = { getUsers: async function (req,res) { @@ -26,6 +27,7 @@ const userControllers = { const Users = await Service.createUser(req.body) if (Users.id) { + const userMail = Users.email const subject = "Usuario creado con éxito ✔ 😉"; const text = `Querido ${Users.name} Tu proyecto se ha creado con éxito. Felicitaciones y gracias por hacer de nuestra comunidad un lugar mejor! ` const html = `

From b9c5784a2293cf6e4d64a61e90fa8af273860b5e Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Fri, 27 Oct 2023 00:42:36 -0300 Subject: [PATCH 57/60] Modifico mensaje de proyecto --- server/src/controllers/form.js | 18 +++++++++++++++--- server/src/controllers/users.js | 6 +++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/src/controllers/form.js b/server/src/controllers/form.js index 896813a..003aca8 100644 --- a/server/src/controllers/form.js +++ b/server/src/controllers/form.js @@ -19,9 +19,21 @@ const formControllers = { const userMail = user.email - const subject = "Proyecto creado con éxito ✔"; - const text = `Querido ${user.name} Tu proyecto se ha creado con éxito. Felicitaciones y gracias por hacer de nuestra comunidad un lugar mejor! ` - const html = "Tu nuevo proyecto ya está ONLINE! 😂 " + const subject = "¡Tu proyecto ha sido creado con éxito! 🚀"; + const text = `Querid@ ${user.name} Tu proyecto se ha creado con éxito. Esto es un gran paso hacia la realización de tu visión.! ` + const html = `

+ Querid@ ${user.name}, +

+ +

Tu proyecto se ha creado con éxito. Esto es un gran paso hacia la realización de tu visión.!

+

Si deseas realizar cambios o actualizar la información de tu proyecto, puedes hacerlo desde tu panel de control

+

No dudes en ponerte en contacto con nuestro equipo de soporte si necesitas ayuda o tienes preguntas adicionales.

+

¡Gracias por ser parte de nuestra comunidad y por compartir tu proyecto con nosotros!

+

Saludos,

+
+

El equipo de ProJunity

+

@2023 ProJunity. Todos los derechos reservados.

+ ` sendEmail(userMail, subject, text, html) res.status(200).json(newProject); diff --git a/server/src/controllers/users.js b/server/src/controllers/users.js index 4fdf686..83cf00e 100644 --- a/server/src/controllers/users.js +++ b/server/src/controllers/users.js @@ -29,16 +29,16 @@ const userControllers = { const userMail = Users.email const subject = "Usuario creado con éxito ✔ 😉"; - const text = `Querido ${Users.name} Tu proyecto se ha creado con éxito. Felicitaciones y gracias por hacer de nuestra comunidad un lugar mejor! ` + const text = `Querid@ ${Users.name} Tu proyecto se ha creado con éxito. Felicitaciones y gracias por hacer de nuestra comunidad un lugar mejor! ` const html = `

- Querido ${Users.name} + Querid@ ${Users.name},

Muchas gracias por formar parte de nuestra comunidad. Esperamos que disfrutes de tu experiencia en nuestro sitio.

Te recordamos que podés ingresar a tu cuenta con tu email y la contraseña que elegiste al registrarte.

¡Te esperamos pronto!

Saludos,

-
+

El equipo de ProJunity

@2023 ProJunity. Todos los derechos reservados.

` From 4bfc70b2ad789821f71710e07182601f43e85c02 Mon Sep 17 00:00:00 2001 From: jesib03 Date: Fri, 27 Oct 2023 07:45:23 -0300 Subject: [PATCH 58/60] push para revisar gestionUsers --- front/pages/admin/gestionUsers.jsx | 72 +++++------------------- front/pages/admin/reportesUser.jsx | 18 ++++++ front/redux/actions/actionsDashboard.js | 2 +- front/redux/reducers/dashboardReducer.js | 18 +----- 4 files changed, 37 insertions(+), 73 deletions(-) diff --git a/front/pages/admin/gestionUsers.jsx b/front/pages/admin/gestionUsers.jsx index 1277142..448a088 100644 --- a/front/pages/admin/gestionUsers.jsx +++ b/front/pages/admin/gestionUsers.jsx @@ -25,71 +25,19 @@ import { import Loader from "../../components/layout/loader"; import { getSesion } from "../../redux/actions/actionsUser"; -// const userData = [ -// { -// id: 1, -// name: "Juan Ponce", -// email: "usuario1@example.com", -// status: "Activo", -// reasonForBlock: "Comportamiento inapropiado", -// reasonForSuspension: "Incumplimiento de términos", -// lastActivities: [ -// "Inició sesión a las 10:30 AM", -// "Publicó un nuevo artículo a las 11:45 AM", -// "Realizó una compra a las 2:15 PM", -// ], -// }, -// { -// id: 2, -// name: "María López", -// email: "maria@example.com", -// status: "Bloqueado", -// reasonForBlock: "Violación de las políticas", -// reasonForSuspension: null, // Este usuario no está suspendido -// lastActivities: [ -// "Inició sesión a las 9:45 AM", -// "Actualizó su perfil a las 10:30 AM", -// "Envió un mensaje a las 12:15 PM", -// ], -// }, -// { -// id: 3, -// name: "Roberto Sánchez", -// email: "roberto@example.com", -// status: "Activo", -// reasonForBlock: null, // Este usuario no está bloqueado -// reasonForSuspension: null, // Este usuario no está suspendido -// lastActivities: [ -// "Inició sesión a las 8:00 AM", -// "Publicó una imagen a las 9:30 AM", -// "Comentó en un artículo a las 11:45 AM", -// ], -// }, -// { -// id: 4, -// name: "Damian Magri", -// email: "daminao@example.com", -// status: "Suspendido", -// reasonForBlock: null, // Este usuario no está bloqueado -// reasonForSuspension: "Inactividad por 30 dias", // Este usuario no está suspendido -// lastActivities: null, -// }, -// ]; export default function GestionUsuarios() { const dispatch = useDispatch(); - React.useEffect(() => { - dispatch(getSesion()); - }, [dispatch]); - + React.useEffect(() => { let sesion = JSON.parse(localStorage.getItem("sesion")); console.log(sesion) if (sesion.id) { console.log(sesion.id) - dispatch(getUsers()); + dispatch(getUsers()); + // dispatch(getSesion()); } }, [dispatch]); @@ -99,6 +47,8 @@ export default function GestionUsuarios() { const loading = useSelector((state) => state.userDashboard.loading); if (loading) return ; + // const sesionId = useSelector((state) => state.usersData.sesion) + const blockUser = (userId) => { // Mostrar una alerta de SweetAlert2 para confirmar el bloqueo del usuario Swal.fire({ @@ -110,8 +60,16 @@ export default function GestionUsuarios() { cancelButtonText: "Cancelar", }).then((result) => { if (result.isConfirmed) { + // if (typeof sesionId?.access === false) { + // Swal.fire({ + // icon: "warning", + // title: "Inicia sesión para seguir con la compra", + // footer: 'Por que no te loggeas primero?', + // }); + // } else { dispatch(deleteUser(userId)); Swal.fire("Bloqueado", "El usuario ha sido bloqueado.", "success"); + // } } }); }; @@ -156,7 +114,7 @@ export default function GestionUsuarios() { ID Nombre - Correo Electrónico + Correo Electrónico Estado Acciones @@ -172,7 +130,7 @@ export default function GestionUsuarios() { {user.id} {user.name} {user.email} - {user.estado} + {user.isBlocked ? "Bloqueado" : "Activo"} + + ); diff --git a/front/pages/admin/historialUser.jsx b/front/pages/admin/historialUser.jsx index f432100..f675ae7 100644 --- a/front/pages/admin/historialUser.jsx +++ b/front/pages/admin/historialUser.jsx @@ -68,7 +68,7 @@ export default function HistorialUsuarios() { const [pdf, setPdf] = useState(null); const [searchUser, setSearchUser] = useState(""); const [currentPage, setCurrentPage] = useState(1); - const itemsPerPage = 5; + const itemsPerPage = 6; // Función para filtrar el historial por usuario const filteredByUser = userHistoryData.filter((historyItem) => diff --git a/front/pages/admin/reportesUser.jsx b/front/pages/admin/reportesUser.jsx index 2c6898b..0e111e5 100644 --- a/front/pages/admin/reportesUser.jsx +++ b/front/pages/admin/reportesUser.jsx @@ -20,6 +20,9 @@ import { useDispatch, useSelector } from "react-redux"; import { getProjects } from "../../redux/actions/actions"; import Swal from "sweetalert2"; import { getUsers } from "../../redux/actions/actionsDashboard"; +import Loader from "../../components/layout/loader"; + + const userReportsData = [ { @@ -82,24 +85,13 @@ export default function ReportesUsuarios() { dispatch(getProjects()); }, [dispatch]); - - React.useEffect(() => { - let sesion = JSON.parse(localStorage.getItem("sesion")); - console.log(sesion) - if (sesion.id) { - console.log(sesion.id) - dispatch(getUsers()); - // dispatch(getSesion()); - } - }, [dispatch]); - const userData = useSelector((state) => state.userDashboard.dataUsers); - console.log(userData); + + const [pdf, setPdf] = useState(null); const loading = useSelector((state) => state.userDashboard.loading); if (loading) return ; - const [pdf, setPdf] = useState(null); const generatePDF = () => { const doc = new jsPDF(); @@ -196,7 +188,7 @@ export default function ReportesUsuarios() { {reportItem.userReported} {reportItem.reason} - + {reportItem.project} From f5cbe126e9140b722ae4018b57e3dab25458adaa Mon Sep 17 00:00:00 2001 From: jesib03 Date: Fri, 27 Oct 2023 20:21:57 -0300 Subject: [PATCH 60/60] ultimos cambiooos --- front/pages/admin/gestionProyectos.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/pages/admin/gestionProyectos.jsx b/front/pages/admin/gestionProyectos.jsx index cbb977a..f4ea9c3 100644 --- a/front/pages/admin/gestionProyectos.jsx +++ b/front/pages/admin/gestionProyectos.jsx @@ -114,7 +114,7 @@ const getCurrentPageProjects = () => { {project.name} {project.Users.map((user) => ( - {user.githubUser} + {user.githubUser} ))}