From 159cce10e46a8033c3879ac2266bcd9f605c21f4 Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Sun, 22 Oct 2023 12:56:04 -0300 Subject: [PATCH 01/86] user --- front/pages/user/[id].js | 25 ++++++++++++++----------- front/redux/actions/actionsUser.js | 12 +++++------- front/redux/reducers/usersReducer.js | 6 +++--- front/redux/types.js | 2 +- server/src/db.js | 2 +- server/src/services/Users.js | 12 ------------ 6 files changed, 24 insertions(+), 35 deletions(-) diff --git a/front/pages/user/[id].js b/front/pages/user/[id].js index 12495832..a2721d84 100644 --- a/front/pages/user/[id].js +++ b/front/pages/user/[id].js @@ -3,7 +3,7 @@ import { useRouter } from "next/router"; import { useDispatch, useSelector } from "react-redux"; import { useEffect, useState } from "react"; -import { getUserId } from "../../redux/actions/actionsUser"; +import { getUsers } from "../../redux/actions/actionsUser"; import LayoutUser from "../../components/layout/layoutUser"; import ProjectCardUser from "../../components/ProjectCardUser"; @@ -23,32 +23,35 @@ const Profile = () => { const dispatch = useDispatch(); const router = useRouter(); const id = router.query.id; - const userId = useSelector((state) => state.usersData.userId) - console.log(userId); + console.log(id); + const users = useSelector((state) => state.usersData.users) + const projects = useSelector((state) => state.projectsData.projectsFilter); + const userInfo = projects.reduce((p) => p.Users[0].id === id); +console.log(projects); + console.log(userInfo); - useEffect(() => { - dispatch(getUserId(id)) dispatch(getProjects()) + dispatch(getUsers()) }, [dispatch, id]); return ( - ProjUnity | {userId.name} + ProjUnity |
- {userId.name} +
@@ -80,11 +83,11 @@ const Profile = () => { Seguir - +
- +
@@ -109,7 +112,7 @@ const Profile = () => { {projects.slice(0, 2).map((proj) => ( { +export const getUsers = (id) => { return async (dispatch) => { try { - const response = await axios( - `https://api.escuelajs.co/api/v1/users/${id}` - ); - + const response = await axios(`${enpointLocal}users`); + return dispatch({ - type: GET_USER_BY_ID, + type: GET_USERS, payload: response.data, }); } catch (error) { diff --git a/front/redux/reducers/usersReducer.js b/front/redux/reducers/usersReducer.js index 587215e6..c7b62c20 100644 --- a/front/redux/reducers/usersReducer.js +++ b/front/redux/reducers/usersReducer.js @@ -1,6 +1,6 @@ import { GET_SESION, - GET_USER_BY_ID, + GET_USERS, GET_USER_BY_NAME, LOGIN, LOGOUT, @@ -17,10 +17,10 @@ const initialState = { const usersReducer = (state = initialState, action) => { switch (action.type) { - case GET_USER_BY_ID: + case GET_USERS: return { ...state, - userId: action.payload, + users: action.payload, loading: false, }; case SET_ALERT: diff --git a/front/redux/types.js b/front/redux/types.js index ddd84eb4..413d353e 100644 --- a/front/redux/types.js +++ b/front/redux/types.js @@ -23,7 +23,7 @@ export const REMOVE_ITEM = "REMOVE_ITEM"; export const GET_ALL_ITEMS = "GET_ALL_ITEMS"; //type users -export const GET_USER_BY_ID = "GET_USER_BY_ID"; +export const GET_USERS = "GET_USERS"; export const LOGIN = "LOGIN"; export const LOGOUT = "LOGOUT"; export const GET_SESION = "GET_SESION"; diff --git a/server/src/db.js b/server/src/db.js index 49019900..895b8c17 100644 --- a/server/src/db.js +++ b/server/src/db.js @@ -38,7 +38,7 @@ let entries = Object.entries(sequelize.models); let capsEntries = entries.map((entry) => [entry[0][0].toUpperCase() + entry[0].slice(1), entry[1]]); sequelize.models = Object.fromEntries(capsEntries); -const { Users, UserTypes, Projects, Category, Tags, Payments, Comments, Ratings, apiauth, UsersTerceros, UsersTerceros } = sequelize.models; +const { Users, UserTypes, Projects, Category, Tags, Payments, Comments, Ratings, apiauth, UsersTerceros } = sequelize.models; // Aca vendrian las relaciones // Product.hasMany(Reviews); diff --git a/server/src/services/Users.js b/server/src/services/Users.js index 2859a255..3e1f38b2 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -91,12 +91,8 @@ const userServices = { return error } }, -<<<<<<< HEAD - updateUser: async function (userData, res) { -======= updateUser: async function (userData, res){ ->>>>>>> c083ce78dc962eede34e9f4daf9cc086b5deed7c try { const { id, name, email, password, image, twitterUser, emailUser, githubUser, linkedinUser, roleId} = userData // find the user by ID @@ -132,20 +128,12 @@ const userServices = { }, deleteUser: async function(userId) { try { -<<<<<<< HEAD - const User = await Users.findByPk(id) - if (User) { - await User.destroy() - } - res.status(200).json(User) -======= const user = await Users.findByPk(userId); if (!user) { throw new Error('User not found'); } await user.destroy(); return { message: 'User deleted successfully' }; ->>>>>>> c083ce78dc962eede34e9f4daf9cc086b5deed7c } catch (error) { throw new Error(error.message); } From 74e4e7b9f35fabc0d81d065ddde3596f1c7b5015 Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Sun, 22 Oct 2023 20:28:22 -0300 Subject: [PATCH 02/86] feed --- front/components/layout/layoutUser.js | 19 ++-- front/components/socialMedia.jsx | 28 +++--- front/pages/user/[id].js | 53 +++++------ front/redux/actions/actionsUser.js | 3 +- front/redux/reducers/usersReducer.js | 1 + server/src/utils/projectsUser.json | 128 +++++++++++++------------- 6 files changed, 113 insertions(+), 119 deletions(-) diff --git a/front/components/layout/layoutUser.js b/front/components/layout/layoutUser.js index 5a087530..b95affcb 100644 --- a/front/components/layout/layoutUser.js +++ b/front/components/layout/layoutUser.js @@ -69,15 +69,16 @@ const LayoutUser = ({ children }) => { }; const handleDashboard = () => { - if (sesion.role === "admin") { - alert("eres admin, wiii!"); - } else { - Swal.fire({ - icon: "error", - title: "Acceso denegado", - text: "No tienes permiso para acceder a esta página.", - }); - } + // if (sesion.role === "admin") { + // alert("eres admin, wiii!"); + // } else { + // Swal.fire({ + // icon: "error", + // title: "Acceso denegado", + // text: "No tienes permiso para acceder a esta página.", + // }); + // } + router.push("/profile") }; return ( diff --git a/front/components/socialMedia.jsx b/front/components/socialMedia.jsx index 110e01cc..3f1cab34 100644 --- a/front/components/socialMedia.jsx +++ b/front/components/socialMedia.jsx @@ -1,36 +1,36 @@ +import { Link, link } from "@nextui-org/react"; import { FaTwitter, FaEnvelope, FaLinkedin, FaGithub } from "react-icons/fa"; -const SocialMedia = ({email}) => { + +const SocialMedia = ({ user }) => { + const { email, githubUser, linkedinUser, twitterUser } = user; return (
- - + - + - + - + - + - + - +
); }; diff --git a/front/pages/user/[id].js b/front/pages/user/[id].js index a2721d84..b1b8c13d 100644 --- a/front/pages/user/[id].js +++ b/front/pages/user/[id].js @@ -23,35 +23,31 @@ const Profile = () => { const dispatch = useDispatch(); const router = useRouter(); const id = router.query.id; - console.log(id); - const users = useSelector((state) => state.usersData.users) - + const projects = useSelector((state) => state.projectsData.projectsFilter); - const userInfo = projects.reduce((p) => p.Users[0].id === id); -console.log(projects); - console.log(userInfo); - + const projectsByUser = projects.filter((p) => Number(p.Users[0]?.id) === Number(id)); + + const users = useSelector((state) => state.usersData.users); + const user = users.filter(u => Number(u.id) === Number(id)); + + + useEffect(() => { dispatch(getProjects()) dispatch(getUsers()) - }, [dispatch, id]); + }, [dispatch]); return ( - ProjUnity | + ProjUnity | {user[0]?.name}
- - + + {user[0]?.name}
@@ -73,46 +69,41 @@ console.log(projects);
- {/* Usuario desde {userId.creationAt.slice(0,10)} */} -
- - - + +
- +
- TOP 3 HR Influencers Spain ✪ FORBES Successful Entrepreneurs ✪ + {/* TOP 3 HR Influencers Spain ✪ FORBES Successful Entrepreneurs ✪ Co-Fundador ✪ Best Selling Author ✪ Mentor Marca Personal y Búsqueda de Empleo ✪ Ayudo a líderes a reclutar mejor con DATA ✪ - Tech-Blockchain-AI-Consultant + Tech-Blockchain-AI-Consultant */}

Proyectos

- {projects.slice(0, 5).map((proj) => ( + {projectsByUser?.map((proj) => ( ))}
-

+

Actividades recientes

{projects.slice(0, 2).map((proj) => ( { switch (action.type) { case GET_USERS: diff --git a/server/src/utils/projectsUser.json b/server/src/utils/projectsUser.json index 24ed1d48..4a721a35 100644 --- a/server/src/utils/projectsUser.json +++ b/server/src/utils/projectsUser.json @@ -1,68 +1,68 @@ { "data": [ - { - "ProjectId": 1, - "UserId": 4 - }, - { - "ProjectId": 2, - "UserId": 8 - }, - { - "ProjectId": 3, - "UserId": 4 - }, - { - "ProjectId": 4, - "UserId": 7 - }, - { - "ProjectId": 6, - "UserId": 4 - }, - { - "ProjectId": 6, - "UserId": 2 - }, - { - "ProjectId": 7, - "UserId": 1 - }, - { - "ProjectId": 8, - "UserId": 2 - }, - { - "ProjectId": 9, - "UserId": 8 - }, - { - "ProjectId": 10, - "UserId": 3 - }, - { - "ProjectId": 11, - "UserId": 2 - }, - { - "ProjectId": 12, - "UserId": 8 - }, - { - "ProjectId": 13, - "UserId": 7 - }, - { - "ProjectId": 14, - "UserId": 2 - }, - { - "ProjectId": 16, - "UserId": 4 - }, - { - "ProjectId": 16, - "UserId": 1 - } + { + "ProjectId": 1, + "UserId": 4 + }, + { + "ProjectId": 2, + "UserId": 8 + }, + { + "ProjectId": 3, + "UserId": 4 + }, + { + "ProjectId": 4, + "UserId": 7 + }, + { + "ProjectId": 6, + "UserId": 2 + }, + { + "ProjectId": 7, + "UserId": 1 + }, + { + "ProjectId": 8, + "UserId": 2 + }, + { + "ProjectId": 9, + "UserId": 8 + }, + { + "ProjectId": 10, + "UserId": 3 + }, + { + "ProjectId": 11, + "UserId": 2 + }, + { + "ProjectId": 12, + "UserId": 8 + }, + { + "ProjectId": 13, + "UserId": 7 + }, + { + "ProjectId": 14, + "UserId": 2 + }, + { + "ProjectId": 16, + "UserId": 4 + }, + { + "ProjectId": 5, + "UserId": 1 + }, + { + "ProjectId": 15, + "UserId": 5 + } ] } \ No newline at end of file From 4ce3f2058e9751a17b18ddd07943cd2ba0ad1f15 Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Mon, 23 Oct 2023 19:57:04 -0300 Subject: [PATCH 03/86] changes user --- front/components/layout/layoutUser.js | 19 ++- .../userDashboard/OrdenesCompra.jsx | 109 +++++++++++++---- front/components/userDashboard/OrderDetail.js | 110 ++++++++++++++++++ front/components/userDashboard/PDFDownload.js | 66 +++++++++++ front/components/userDashboard/buttonEdit.jsx | 10 +- front/pages/profile/index.js | 6 +- front/redux/types.js | 3 + 7 files changed, 284 insertions(+), 39 deletions(-) create mode 100644 front/components/userDashboard/OrderDetail.js create mode 100644 front/components/userDashboard/PDFDownload.js diff --git a/front/components/layout/layoutUser.js b/front/components/layout/layoutUser.js index b95affcb..5a087530 100644 --- a/front/components/layout/layoutUser.js +++ b/front/components/layout/layoutUser.js @@ -69,16 +69,15 @@ const LayoutUser = ({ children }) => { }; const handleDashboard = () => { - // if (sesion.role === "admin") { - // alert("eres admin, wiii!"); - // } else { - // Swal.fire({ - // icon: "error", - // title: "Acceso denegado", - // text: "No tienes permiso para acceder a esta página.", - // }); - // } - router.push("/profile") + if (sesion.role === "admin") { + alert("eres admin, wiii!"); + } else { + Swal.fire({ + icon: "error", + title: "Acceso denegado", + text: "No tienes permiso para acceder a esta página.", + }); + } }; return ( diff --git a/front/components/userDashboard/OrdenesCompra.jsx b/front/components/userDashboard/OrdenesCompra.jsx index 0a7fcd42..e4daaecc 100644 --- a/front/components/userDashboard/OrdenesCompra.jsx +++ b/front/components/userDashboard/OrdenesCompra.jsx @@ -1,3 +1,4 @@ +import { useState } from "react"; import { Table, TableHeader, @@ -8,8 +9,12 @@ import { getKeyValue, Select, SelectItem, - Input + Input, + Link, + Button } from "@nextui-org/react"; +import { PDFDownload } from "./PDFDownload"; +import OrderDetail from "./OrderDetail"; const columns = [ { @@ -32,10 +37,18 @@ const columns = [ key: "price", label: "PRECIO", }, + { + key: "detalle", + label: "VER DETALLES", + }, + { + key: "descarga", + label: "DESCARGAR PDF", + }, ]; const rows = [ { - key: "1", + key: 1, compra: "2AWERF45", date: "04/06/2023", status: "Facturada", @@ -43,24 +56,24 @@ const rows = [ price: "34", }, { - key: "2", - compra: "2AWERF45", + key: 2, + compra: "2AWERF46", date: "04/06/2023", status: "Facturada", product: "Laravel", price: "34", }, { - key: "3", - compra: "2AWERF45", + key: 3, + compra: "2AWERF47", date: "04/06/2023", status: "Facturada", product: "Laravel", price: "34", }, { - key: "4", - compra: "2AWERF45", + key: 4, + compra: "2AWERF48", date: "04/06/2023", status: "Cancelada", product: "Laravel", @@ -69,6 +82,20 @@ const rows = [ ]; const OrdenesCompra = () => { + +//buscar por orden de compra +const [compra, setCompra] = useState(""); +const searchBuy = rows.filter((r) => + r.compra.toUpperCase().includes(compra.toUpperCase()) + ); + + //filtrar por estado de la compra + // const [filter, setFilter] = useState([]) + // const filterOrders = () => { + + // } + + return (
@@ -77,9 +104,9 @@ const OrdenesCompra = () => { label="Estado" className="w-32 mt-4 mb-4 text-black" > - Todos - Facturada - Cancelada + Todos + Facturada + Cancelada { label="N° de Compra" className="w-64 mt-4 mb-4 text-black ml-8" mr="2" + onChange={(e) => setCompra(e.target.value)} /> - - + */}
{ radius="none" fullWidth="true" > - {(column) => ( + {/* {(column) => ( {column.label} - )} + )} */} + N° COMPRA + N° COMPRA + N° COMPRA + N° COMPRA + N° COMPRA + N° COMPRA + N° COMPRA - - {(item) => ( + + {/* {(item) => ( {(columnKey) => ( {getKeyValue(item, columnKey)} )} - )} + )} */} + + {searchBuy.map((order) => ( + + {order.compra} + {order.date} + {order.price} + {order.status} + {order.product} + + + {/* y */} + {/* */} + + {/* */} + + + + + + ))}
diff --git a/front/components/userDashboard/OrderDetail.js b/front/components/userDashboard/OrderDetail.js new file mode 100644 index 00000000..a76c296e --- /dev/null +++ b/front/components/userDashboard/OrderDetail.js @@ -0,0 +1,110 @@ +import { useState } from "react"; +import {Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button, useDisclosure} from "@nextui-org/react"; + +const order = [ + { + key: 1, + compra: "2AWERF45", + date: "04/06/2023", + status: "Facturada", + product: "Laravel", + price: "34", + description: "hoola mundo", + desarrollador: "steve jobs", + }, + { + key: 2, + compra: "2AWERF46", + date: "04/06/2023", + status: "Facturada", + product: "Laravel", + price: "34", + description: "hoola mundo", + desarrollador: "steve jobs", + }, + { + key: 3, + compra: "2AWERF47", + date: "04/06/2023", + status: "Facturada", + product: "Laravel", + price: "34", + description: "hoola mundo", + desarrollador: "steve jobs", + }, + { + key: 4, + compra: "2AWERF48", + date: "04/06/2023", + status: "Cancelada", + product: "Laravel", + price: "34", + description: "hoola mundo", + desarrollador: "steve jobs", + }, +]; +const OrderDetail = ({id}) => { + + // const router = useRouter(); + // const { id } = router.query; + console.log(id); + const orderDetail = order.filter((o) =>o.key === Number(id)) + console.log(orderDetail); + + const { isOpen, onOpen, onClose } = useDisclosure(); + const [backdrop, setBackdrop] = useState("blur"); + const [size, setSize] = useState("3xl"); + + const handleOpen = (size) => { + // setBackdrop(backdrop); +setSize(size) + onOpen(); + }; + + return ( +
+ <> +
+ +
+ + + {(onClose) => ( + <> + +

+ Detalle - Orden de compra N°: {orderDetail[0]?.compra} +

+
+ +

Fecha: {orderDetail[0]?.date}

+

Estados: {orderDetail[0]?.status}

+

Desarrollador: {orderDetail[0]?.desarrollador}

+

Producto: {orderDetail[0]?.product}

+

Precio: ${orderDetail[0]?.price}

+

Descripción: {orderDetail[0]?.description}

+
+ + + + + )} +
+
+ +
+ ); +}; + +export default OrderDetail; diff --git a/front/components/userDashboard/PDFDownload.js b/front/components/userDashboard/PDFDownload.js new file mode 100644 index 00000000..1c2d5ee3 --- /dev/null +++ b/front/components/userDashboard/PDFDownload.js @@ -0,0 +1,66 @@ +import { jsPDF} from "jspdf"; +import "jspdf-autotable"; + +export const PDFDownload = () => { + // Crear un nuevo documento PDF + const doc = new jsPDF("l"); + doc.setFont("helvetica"); + doc.setFontSize(30); + doc.text("Orden de compra", 145, 20, null, null, "center"); + + // Agregar contenido al PDF + +// doc.text("Orden de compra", 105, 15, 15, null, "center"); +// doc.addFont("/fonts/Pompiere-Regular.ttf", "Pompiere", "regular"); + doc.autoTable({ + startY: 28, + theme: "striped", + styles: { + fontSize: 5, + overflow: "linebreak", + cellPadding: 2, + lineColor: [0, 0, 0], + lineWidth: 0.2, + }, + headStyles: { + valign: "middle", + halign: "center", + fontSize: 15, + fillColor: [255, 255, 255], + textColor: [0, 0, 0], + }, + tableLineColor: [0, 0, 0], + tableLineWidth: 0.5, + columnStyles: { + 0: { + halign: "center", + }, + 1: { + halign: "center", + }, + 2: { + halign: "center", + }, + 3: { + halign: "center", + }, + 4: { + halign: "center", + }, + 5: { + halign: "left", + }, + }, + bodyStyles: { + fillColor: [255, 255, 255], + textColor: 0, + fontSize: 10, + minCellHeight: 15, + }, + head: [["Fecha", "N° Compra", "Estado", "Producto", "Precio", "desarrollador"]], + body: [["17/06/2023", "AE345TG", "CANCELADA", "LARAVEL", "$45", "Steve "]], + }); + + // Descargar el PDF + doc.save("Compra.pdf"); +}; diff --git a/front/components/userDashboard/buttonEdit.jsx b/front/components/userDashboard/buttonEdit.jsx index 63ee9519..86687ef9 100644 --- a/front/components/userDashboard/buttonEdit.jsx +++ b/front/components/userDashboard/buttonEdit.jsx @@ -5,9 +5,11 @@ import { ModalHeader, ModalFooter, useDisclosure, + Link } from "@nextui-org/react"; const ButtonEdit = () => { + const { isOpen, onOpen, onOpenChange } = useDisclosure(); return (
@@ -26,16 +28,16 @@ const ButtonEdit = () => { {(onClose) => ( <> - ¿Quieres editar este proyecto? + ¿Quieres editar este proyecto? - + + + )} diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index 0be28fdf..1b6769e5 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -24,13 +24,11 @@ const Profile = () => { // const userName = useSelector((state) => state.usersData.users); - // const projects = useSelector((state) => state.projectsData.projectsFilter); + const projects = useSelector((state) => state.projectsData.projectsFilter); // console.log(userName); // const dispatch = useDispatch(); - // useEffect(() => { - // dispatch(getUserByName(name)); - // }, [dispatch]); + return ( diff --git a/front/redux/types.js b/front/redux/types.js index 1b694ef8..ffc99514 100644 --- a/front/redux/types.js +++ b/front/redux/types.js @@ -39,3 +39,6 @@ export const GET_ALL_COMMENTS = "GET_ALL_COMMENTS"; //endpoint export const ENDPOINT = "http://localhost:3001/"; +//dashboardUser +export const FILTER_ORDENES = "FILTER_ORDENES"; +export const GET_ORDENES_BY_NUMBER = "GET_ORDENES_BY_NUMBER"; From 53e94789cd926af9780395ecd8e0fb90913fce7d Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Mon, 23 Oct 2023 20:48:04 -0300 Subject: [PATCH 04/86] changes --- front/components/userDashboard/OrderDetail.js | 4 +-- .../components/userDashboard/chartsViews.jsx | 8 ++--- .../components/userDashboard/projDashUser.jsx | 20 +++++++++-- front/pages/profile/index.js | 36 +++++++++++-------- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/front/components/userDashboard/OrderDetail.js b/front/components/userDashboard/OrderDetail.js index a76c296e..3af62367 100644 --- a/front/components/userDashboard/OrderDetail.js +++ b/front/components/userDashboard/OrderDetail.js @@ -47,9 +47,9 @@ const OrderDetail = ({id}) => { // const router = useRouter(); // const { id } = router.query; - console.log(id); + const orderDetail = order.filter((o) =>o.key === Number(id)) - console.log(orderDetail); + const { isOpen, onOpen, onClose } = useDisclosure(); const [backdrop, setBackdrop] = useState("blur"); diff --git a/front/components/userDashboard/chartsViews.jsx b/front/components/userDashboard/chartsViews.jsx index ab77ec49..3a1bff8b 100644 --- a/front/components/userDashboard/chartsViews.jsx +++ b/front/components/userDashboard/chartsViews.jsx @@ -10,11 +10,9 @@ const data = [ { name: "Jun", views: 0 }, { name: "July", views: 20 }, ]; -const Example = () => { -// export default class Example extends PureComponent { -// static demoUrl = 'https://codesandbox.io/s/line-chart-connect-nulls-sqp96'; - -// render() { +const Example = ({views}) => { + // const { views } = views; + console.log(views.views); return (
{/* diff --git a/front/components/userDashboard/projDashUser.jsx b/front/components/userDashboard/projDashUser.jsx index 4d0a7c34..2ea7cb88 100644 --- a/front/components/userDashboard/projDashUser.jsx +++ b/front/components/userDashboard/projDashUser.jsx @@ -1,15 +1,29 @@ import ButtonEdit from "./buttonEdit"; -import {Button, Link} from "@nextui-org/react"; +import {Button, Link, Image} from "@nextui-org/react"; import React, { useState } from "react"; - +// commentsAllowed: true; +// createdAt: "2023-10-23T22:44:25.525Z"; +// deletedAt: null; +// description: "Un flanger gratuito de la fantástica compañía Valhalla. Once algoritmos para obtener todo tipo de efectos que desafían cualquier descripción. A destacar los efectos que podemos conseguir automatizando los parámetros en nuestro DAW o mediante un teclado controlador MIDI."; +// id: 7; +// image: "https://val-media-offload.s3.amazonaws.com/wp-content/uploads/2016/06/08073920/ValhallaSpaceModGUI-960x437.jpg"; +// name: "Valhalla Space Modulator"; +// price: "0.00"; +// shortDescription: "Un flanger gratuito de la fantástica compañía Valhalla."; +// status: "Canceled"; +// updatedAt: "2023-10-23T22:44:25.525Z"; +// views: 25; const ProjDashUser = () => { - const [active, setActive] = useState(false); + + + const [active, setActive] = useState(true); return (
+
diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index 1b6769e5..518cd59f 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -14,21 +14,24 @@ import Posts from "../../components/userDashboard/posts"; import Example from "../../components/userDashboard/chartsViews"; import DownloadCharts from "../../components/userDashboard/downloadCharts"; import OrdenesCompra from "../../components/userDashboard/OrdenesCompra"; - +import { getProjects } from "../../redux/actions/actions"; const Profile = () => { - const router = useRouter(); + const dispatch = useDispatch(); const sesion = useSelector((state) => state.usersData.sesion); console.log(sesion); - - + // const { id } = sesion + // console.log(id); - // const userName = useSelector((state) => state.usersData.users); - const projects = useSelector((state) => state.projectsData.projectsFilter); - // console.log(userName); - // const dispatch = useDispatch(); + const projects = useSelector((state) => state.projectsData.projectsFilter); + const projectsByUser = projects.filter( + (p) => Number(p.Users[0]?.id) === 1); + console.log(projectsByUser); - + useEffect(() => { + dispatch(getProjects()); + + }, [dispatch]); return ( @@ -86,21 +89,24 @@ const Profile = () => {

Proyectos

- - - + {/* {projectsByUser?.map((proj) => ( + + ))} */}

Summary

{/*

View More

*/}

Vistas

- + {projectsByUser?.map((proj) => ( + + ))} +

Descargas

- +

Promociones

@@ -132,7 +138,7 @@ const Profile = () => {

Historial de compras

- +
); From d3cca88f894da19744ea7ff9ce9cafa314c3106e Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 08:32:06 -0300 Subject: [PATCH 05/86] =?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 f5c4bd57..e083a72c 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 06/86] 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 3db1e99c..cc38c5b8 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 d1aac6eb..d231ca06 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 2f2212516d7f323465c61b3fcd2a9c077ea55cab Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Tue, 24 Oct 2023 15:55:36 -0300 Subject: [PATCH 07/86] changes --- server/index.js | 34 +++++++++++++++++----------------- server/src/services/Users.js | 8 -------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/server/index.js b/server/index.js index c5c0d22b..0ace8911 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: false }) + .sync({ force: true }) .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 ProjectTags.bulkCreate(projectTags); + await Tags.bulkCreate(tags); + await Ratings.bulkCreate(ratings); + await ProjectUser.bulkCreate(projectUser.data); + await ProjectCategory.bulkCreate(projectCategory); console.log(`Server listening on port ${PORT}`); }); diff --git a/server/src/services/Users.js b/server/src/services/Users.js index 224ace89..1ab86672 100644 --- a/server/src/services/Users.js +++ b/server/src/services/Users.js @@ -38,21 +38,13 @@ const userServices = { {name: {[Op.iLike]: `${name}%`}}, ], [Op.and]: [{active: 'true'}]}, -<<<<<<< HEAD - attributes: ['id', 'name','email', 'image', 'twitterUser','emailUser','githubUser','role'] -======= attributes: ['id', 'name','email', 'image', 'twitterUser','emailUser','githubUser','linkedinUser','role'] ->>>>>>> 920f1c9981dc198a34064878ac667f0c10edc0bc }) return response } else { const response = await Users.findAll({ where: {active: 'true'}, -<<<<<<< HEAD - attributes: ['id','name','email', 'image', 'twitterUser','emailUser','githubUser','role'] -======= attributes: ['id','name','email', 'image', 'twitterUser','emailUser','githubUser', 'linkedinUser','role'] ->>>>>>> 920f1c9981dc198a34064878ac667f0c10edc0bc }) return response } From 8b1d3d795d611008b9c925dfa9197c58ad419195 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Tue, 24 Oct 2023 16:50:22 -0300 Subject: [PATCH 08/86] 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 08ee94ec..d11877c7 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 9be00c84..90adbebf 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 028f626b..896813a6 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 00000000..bdbdfbc6 --- /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 17084130..4949688e 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 09/86] 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 d231ca06..df23d71d 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 10/86] 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 df23d71d..c9c45d99 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 11/86] 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 cc38c5b8..1219bfc9 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 c9c45d99..52be7386 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 12/86] 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 1219bfc9..00311f84 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 00e2d0db468c9f497eac37c27f2abbe892faaffc Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Tue, 24 Oct 2023 23:22:46 -0300 Subject: [PATCH 13/86] changes --- front/components/userDashboard/buttonEdit.jsx | 4 +- .../components/userDashboard/chartsViews.jsx | 2 +- .../components/userDashboard/projDashUser.jsx | 26 +- front/pages/profile/index.js | 311 ++++++++++++++---- front/redux/actions/actionsUser.js | 4 +- front/redux/types.js | 4 +- server/index.js | 7 +- server/package.json | 2 +- server/src/controllers/mercadopago.js | 10 +- 9 files changed, 269 insertions(+), 101 deletions(-) diff --git a/front/components/userDashboard/buttonEdit.jsx b/front/components/userDashboard/buttonEdit.jsx index 86687ef9..36ed2f07 100644 --- a/front/components/userDashboard/buttonEdit.jsx +++ b/front/components/userDashboard/buttonEdit.jsx @@ -8,8 +8,8 @@ import { Link } from "@nextui-org/react"; -const ButtonEdit = () => { - +const ButtonEdit = ({id}) => { +// console.log(id); const { isOpen, onOpen, onOpenChange } = useDisclosure(); return (
diff --git a/front/components/userDashboard/chartsViews.jsx b/front/components/userDashboard/chartsViews.jsx index 3a1bff8b..6cbb960a 100644 --- a/front/components/userDashboard/chartsViews.jsx +++ b/front/components/userDashboard/chartsViews.jsx @@ -12,7 +12,7 @@ const data = [ ]; const Example = ({views}) => { // const { views } = views; - console.log(views.views); + // console.log(views.views); return (
{/* diff --git a/front/components/userDashboard/projDashUser.jsx b/front/components/userDashboard/projDashUser.jsx index 2ea7cb88..2364f84e 100644 --- a/front/components/userDashboard/projDashUser.jsx +++ b/front/components/userDashboard/projDashUser.jsx @@ -2,6 +2,7 @@ import ButtonEdit from "./buttonEdit"; import {Button, Link, Image} from "@nextui-org/react"; import React, { useState } from "react"; + // commentsAllowed: true; // createdAt: "2023-10-23T22:44:25.525Z"; // deletedAt: null; @@ -14,18 +15,23 @@ import React, { useState } from "react"; // status: "Canceled"; // updatedAt: "2023-10-23T22:44:25.525Z"; // views: 25; -const ProjDashUser = () => { - +const ProjDashUser = ({proj}) => { + // console.log(proj); + - const [active, setActive] = useState(true); + // const [active, setActive] = useState(true); return (
-
-
+
+ {/* */} +
+
+
+ {/*

{name}

*/}
diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index c10aaa25..a0eb97f3 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -1,9 +1,8 @@ import { useRouter } from "next/router"; +// import ButtonEdit from "../../components/userDashboard/buttonEdit"; import { useDispatch, useSelector } from "react-redux"; -import { useEffect } from "react"; - +import Loader from "../../components/layout/loader" import LayoutUser from "../../components/layout/layoutUser"; - import Head from "next/head"; import ProjDashUser from "../../components/userDashboard/projDashUser"; @@ -16,23 +15,66 @@ import DownloadCharts from "../../components/userDashboard/downloadCharts"; import OrdenesCompra from "../../components/userDashboard/OrdenesCompra"; import { getProjects } from "../../redux/actions/actions"; +import { useEffect, useState } from "react"; +import { + Bar, + BarChart, + LineChart, + Line, + XAxis, + YAxis, + CartesianGrid, + Tooltip, + Legend, + ResponsiveContainer, +} from "recharts"; +import { + Button, + Modal, + ModalContent, + ModalHeader, + ModalFooter, + useDisclosure, + Link, Image +} from "@nextui-org/react"; + + + const Profile = () => { - const dispatch = useDispatch(); - const sesion = useSelector((state) => state.usersData.sesion); - console.log(sesion); - // const { id } = sesion - // console.log(id); - const projects = useSelector((state) => state.projectsData.projectsFilter); - const projectsByUser = projects.filter( - (p) => Number(p.Users[0]?.id) === 1); - console.log(projectsByUser); +const { isOpen, onOpen, onOpenChange } = useDisclosure(); +const dispatch = useDispatch(); +useEffect(() => { + dispatch(getProjects()); +}, [dispatch]); - useEffect(() => { - dispatch(getProjects()); - - }, [dispatch]); +const sesion = useSelector((state) => state.usersData.sesion); +const projects = useSelector((state) => state.projectsData.projects); +// console.log(projects); +const projectsByUser = projects.filter( + (p) => Number(p.Users[0]?.id) === Number(2)); //sesion.id +console.log(projectsByUser); + const viewsByProject = projectsByUser.map(p => { + return { + name: p.name, + views: p.views + }; + }); + // console.log(viewsByProject); + const ratingByProject = projectsByUser?.map((p) => { + return { + name: p.name, + rating: p.Ratings[0]?.score ? p.Ratings[0].score :

No hay rating para este proyecto

, + }; + }); + console.log(ratingByProject); + + const [active, setActive] = useState(true) + + const loading = useSelector((state) => state.projectsData.loading); + //* Aqui se maneja el loader + if (loading) return ; return ( @@ -40,9 +82,6 @@ const Profile = () => {
- - -

Panel de {sesion.name}

@@ -66,17 +105,16 @@ const Profile = () => {
- - +
-

+ {/*

Promociones -

+

*/}

Solicitudes

@@ -87,62 +125,189 @@ const Profile = () => { Historial de Compras

- -
-

Proyectos

-
-
- {/* {projectsByUser?.map((proj) => ( - - ))} */} -
-
-

Summary

- {/*

View More

*/} -

Vistas

- {projectsByUser?.map((proj) => ( - - ))} - -

Descargas

- + +
+

Proyectos

+
+
+ {projectsByUser.map((proj) => ( +
+
+ {proj.name} +
+
+

{proj.name}

+
+
+ {/* buton edit */} +
+ + + + {(onClose) => ( + <> + + ¿Quieres editar este proyecto? + + + + + + + + + + )} + + +
+
+ + + + +
+
+
+
+
+ ))} + + + +
+
+

Summary

+ + {/* GRAFICO DE VISTAS */} +

Vistas

+ +
+ + + + + + + + + +
+ {/* GRAFICO DE RATING */} +

Rating

+
+ + + + + + + + + +
+
-
- -
-

Promociones

-
-
- - + {/* +
+

Promociones

+
+
+ + +
+
+

Summary

+

View More

+

Vistas

+ +

Descargas

+ +
-
-

Summary

- {/*

View More

*/} -

Vistas

- -

Descargas

- +
*/} +
+

Solicitudes

+
+ +
+ +
+
+

Posts

+
-
-
-

Solicitudes

-
- - +
+

Historial de compras

+
- -
-
-

Posts

- -
-
-

Historial de compras

- -
); diff --git a/front/redux/actions/actionsUser.js b/front/redux/actions/actionsUser.js index f6e2b83c..7405a147 100644 --- a/front/redux/actions/actionsUser.js +++ b/front/redux/actions/actionsUser.js @@ -20,9 +20,7 @@ const endpoint = ENDPOINT; export const getUsers = (id) => { return async (dispatch) => { try { - const response = await axios( - `https://api.escuelajs.co/api/v1/users/${id}` - ); + const response = await axios(`${enpointLocal}users`); diff --git a/front/redux/types.js b/front/redux/types.js index e0329643..f8e7152e 100644 --- a/front/redux/types.js +++ b/front/redux/types.js @@ -37,8 +37,8 @@ export const GET_ALL_COMMENTS = "GET_ALL_COMMENTS"; //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/"; //dashboardUser export const FILTER_ORDENES = "FILTER_ORDENES"; diff --git a/server/index.js b/server/index.js index 0ace8911..407152e1 100644 --- a/server/index.js +++ b/server/index.js @@ -44,13 +44,12 @@ conn 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 Tags.bulkCreate(tags); await Payments.bulkCreate(payments); + await ProjectComments.bulkCreate(commentsProject); + await ProjectRatings.bulkCreate(projectsRatings); await ProjectTags.bulkCreate(projectTags); - await Tags.bulkCreate(tags); - await Ratings.bulkCreate(ratings); await ProjectUser.bulkCreate(projectUser.data); await ProjectCategory.bulkCreate(projectCategory); diff --git a/server/package.json b/server/package.json index 9be00c84..7632a936 100644 --- a/server/package.json +++ b/server/package.json @@ -4,7 +4,7 @@ "description": "Server Proyecto Final", "main": "index.js", "scripts": { - "start": "node ./index.js" + "start": "nodemon -L" }, "author": "", "license": "ISC", diff --git a/server/src/controllers/mercadopago.js b/server/src/controllers/mercadopago.js index 0f7669f7..c8b91eb9 100644 --- a/server/src/controllers/mercadopago.js +++ b/server/src/controllers/mercadopago.js @@ -1,14 +1,14 @@ const mercadopago = require("mercadopago"); const { MP_TOKEN, DB_HOST, CLIENT_HOST } = process.env; -const { Order_detail, Order, Payments, Users } = require("../db.js"); +// const { Order_detail, Order, Payments, Users } = require("../db.js"); const paymentsServices = require("../services/payment.js"); const { Sequelize } = require("sequelize"); const { projects } = require("../utils/index.js"); -const mercadopago = require('mercadopago'); -const {MP_TOKEN, DB_HOST} = process.env +// const mercadopago = require('mercadopago'); + const { Order_detail , Order, Payments, Users, Projects } = require('../db.js'); -const paymentsServices = require('../services/payment.js'); -const {Sequelize} = require('sequelize'); +// const paymentsServices = require('../services/payment.js'); +// const {Sequelize} = require('sequelize'); // Configura las credenciales de MercadoPago const paymenntsControllers = { From 909ea330b6955dc252fad088022ab07ab3a5cf04 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Wed, 25 Oct 2023 01:39:26 -0300 Subject: [PATCH 14/86] =?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 00311f84..2ab47528 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 4949688e..def5f3ca 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 f86192b7..3d9ecbde 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 41b870cb..ad2e130f 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 e083a72c..68a125d5 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 1ab86672..2ae83d2c 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 52be7386..c7126b3c 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 37fedddb457bf6ea2ef5ab8233130c9a693e9af7 Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Wed, 25 Oct 2023 15:22:35 -0300 Subject: [PATCH 15/86] changes --- .../userDashboard/OrdenesCompra.jsx | 16 +++++++- front/components/userDashboard/posts.jsx | 2 +- front/pages/profile/index.js | 38 +++++++++---------- front/redux/actions/actionsPayments.js | 24 ++++++++++++ front/redux/reducers/paymentReducer.js | 21 ++++++++++ front/redux/reducers/reducer.js | 2 + front/redux/types.js | 3 ++ 7 files changed, 84 insertions(+), 22 deletions(-) create mode 100644 front/redux/actions/actionsPayments.js create mode 100644 front/redux/reducers/paymentReducer.js diff --git a/front/components/userDashboard/OrdenesCompra.jsx b/front/components/userDashboard/OrdenesCompra.jsx index 62c4dd32..c0188110 100644 --- a/front/components/userDashboard/OrdenesCompra.jsx +++ b/front/components/userDashboard/OrdenesCompra.jsx @@ -1,4 +1,5 @@ -import { useState } from "react"; +import { useState, useEffect } from "react"; +import { useDispatch, useSelector } from "react-redux"; import { Table, TableHeader, @@ -14,6 +15,8 @@ import { Button } from "@nextui-org/react"; import { PDFDownload } from "./PDFDownload"; +import { getOrder } from "../../redux/actions/actionsPayments"; + import OrderDetail from "./OrderDetail"; const columns = [ @@ -81,8 +84,17 @@ const rows = [ }, ]; -const OrdenesCompra = () => { +const OrdenesCompra = ({id}) => { +console.log(id); + + const dispatch = useDispatch(); + useEffect(() => { + dispatch(getOrder()); + }, [dispatch]); + const orders = useSelector((state) => state.paymentData.payments); + console.log(orders); + //buscar por orden de compra const [compra, setCompra] = useState(""); const searchBuy = rows.filter((r) => diff --git a/front/components/userDashboard/posts.jsx b/front/components/userDashboard/posts.jsx index 2a1bbe45..0ad607fe 100644 --- a/front/components/userDashboard/posts.jsx +++ b/front/components/userDashboard/posts.jsx @@ -17,7 +17,7 @@ const Posts = () => {

Comentarios

- + {/* */}
diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index a0eb97f3..9ce2f765 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -42,33 +42,33 @@ import { const Profile = () => { -const { isOpen, onOpen, onOpenChange } = useDisclosure(); -const dispatch = useDispatch(); -useEffect(() => { - dispatch(getProjects()); -}, [dispatch]); - -const sesion = useSelector((state) => state.usersData.sesion); -const projects = useSelector((state) => state.projectsData.projects); + const dispatch = useDispatch(); + useEffect(() => { + dispatch(getProjects()); + }, [dispatch]); + + const sesion = useSelector((state) => state.usersData.sesion); + const projects = useSelector((state) => state.projectsData.projects); // console.log(projects); const projectsByUser = projects.filter( (p) => Number(p.Users[0]?.id) === Number(2)); //sesion.id console.log(projectsByUser); - const viewsByProject = projectsByUser.map(p => { - return { - name: p.name, - views: p.views - }; - }); - // console.log(viewsByProject); - const ratingByProject = projectsByUser?.map((p) => { +const viewsByProject = projectsByUser.map(p => { + return { + name: p.name, + views: p.views + }; +}); +// console.log(viewsByProject); +const ratingByProject = projectsByUser?.map((p) => { return { name: p.name, rating: p.Ratings[0]?.score ? p.Ratings[0].score :

No hay rating para este proyecto

, }; }); console.log(ratingByProject); - + + const { isOpen, onOpen, onOpenChange } = useDisclosure(); const [active, setActive] = useState(true) @@ -97,7 +97,7 @@ console.log(projectsByUser); - 7 + {projectsByUser.views} 45 12 @@ -306,7 +306,7 @@ console.log(projectsByUser);

Historial de compras

- +
diff --git a/front/redux/actions/actionsPayments.js b/front/redux/actions/actionsPayments.js new file mode 100644 index 00000000..8631ab7f --- /dev/null +++ b/front/redux/actions/actionsPayments.js @@ -0,0 +1,24 @@ +import { + GET_ORDER, + ENDPOINT, +} from "../types"; + +const endpoint = ENDPOINT; + +export const getOrder = () => { + return async (dispatch) => { + try { + const response = await axios(`${endpoint}payment`); +console.log(response); + return dispatch({ + type: GET_ORDER, + payload: response.data, + }); + } catch (error) { + // return dispatch({ + // type: SET_ALERT, + // payload: { type: "error", msg: error.message }, + // }); + } + }; +}; diff --git a/front/redux/reducers/paymentReducer.js b/front/redux/reducers/paymentReducer.js new file mode 100644 index 00000000..63a317fb --- /dev/null +++ b/front/redux/reducers/paymentReducer.js @@ -0,0 +1,21 @@ +import { GET_ORDER } from "../types"; + +const initialState = { + payments: [], + loading: true, +}; + + const paymentReducer = (state = initialState, action) => { + switch (action.type) { + case GET_ORDER: + return { + ...state, + payments: action.payload, + loading: false, + }; + default: + return state; + } + }; + + export default paymentReducer; \ No newline at end of file diff --git a/front/redux/reducers/reducer.js b/front/redux/reducers/reducer.js index d7e207cb..1b7900ef 100644 --- a/front/redux/reducers/reducer.js +++ b/front/redux/reducers/reducer.js @@ -3,10 +3,12 @@ import projectsReducer from "./projectsReducer"; import usersReducer from "./usersReducer"; import carritoReducer from "./carritoReducer"; import commentsReducer from "./commentsReducer"; +import paymentReducer from "./paymentReducer"; export default combineReducers({ projectsData: projectsReducer, carritoData: carritoReducer, usersData: usersReducer, commentData: commentsReducer, + paymentData: paymentReducer, }); diff --git a/front/redux/types.js b/front/redux/types.js index f8e7152e..a008d975 100644 --- a/front/redux/types.js +++ b/front/redux/types.js @@ -43,3 +43,6 @@ export const GET_ALL_COMMENTS = "GET_ALL_COMMENTS"; //dashboardUser export const FILTER_ORDENES = "FILTER_ORDENES"; export const GET_ORDENES_BY_NUMBER = "GET_ORDENES_BY_NUMBER"; + +//payments +export const GET_ORDER = "GET_ORDER"; \ No newline at end of file From ea8264f455920395a6864fc49b0692634f5317d9 Mon Sep 17 00:00:00 2001 From: Laura Grisanzio Date: Wed, 25 Oct 2023 16:07:46 -0300 Subject: [PATCH 16/86] changes --- .../userDashboard/OrdenesCompra.jsx | 1 + front/pages/profile/index.js | 8 +- server/package-lock.json | 108 ++++++++++++++++++ server/package.json | 3 +- 4 files changed, 116 insertions(+), 4 deletions(-) diff --git a/front/components/userDashboard/OrdenesCompra.jsx b/front/components/userDashboard/OrdenesCompra.jsx index c0188110..3b53185f 100644 --- a/front/components/userDashboard/OrdenesCompra.jsx +++ b/front/components/userDashboard/OrdenesCompra.jsx @@ -88,6 +88,7 @@ const OrdenesCompra = ({id}) => { console.log(id); const dispatch = useDispatch(); + useEffect(() => { dispatch(getOrder()); }, [dispatch]); diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index 9ce2f765..a09f8681 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -37,6 +37,7 @@ import { useDisclosure, Link, Image } from "@nextui-org/react"; +import { getSesion } from "../../redux/actions/actionsUser"; @@ -44,10 +45,11 @@ const Profile = () => { const dispatch = useDispatch(); useEffect(() => { - dispatch(getProjects()); + dispatch(getProjects()) }, [dispatch]); const sesion = useSelector((state) => state.usersData.sesion); + const projects = useSelector((state) => state.projectsData.projects); // console.log(projects); const projectsByUser = projects.filter( @@ -78,13 +80,13 @@ const ratingByProject = projectsByUser?.map((p) => { return ( - ProjUnity | {sesion.name} + ProjUnity | {sesion?.name}
-

Panel de {sesion.name}

+

Panel de {sesion?.name}

diff --git a/server/package-lock.json b/server/package-lock.json index 08ee94ec..4a0c35b4 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 c0ebe33d..6038b96c 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", From dab6ba6af8deb7bcd67edd3e27f3cf913bae289b Mon Sep 17 00:00:00 2001 From: jhosno Date: Wed, 25 Oct 2023 16:46:38 -0400 Subject: [PATCH 17/86] Agregando loader para evitar que se crashee la pagina --- front/pages/profile/index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index bfa83937..45ddc377 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -1,8 +1,9 @@ import { useRouter } from "next/router"; import { useDispatch, useSelector } from "react-redux"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import LayoutUser from "../../components/layout/layoutUser"; +import Loader from "../../components/layout/loader"; import Head from "next/head"; @@ -14,14 +15,20 @@ import Posts from "../../components/userDashboard/posts"; import Example from "../../components/userDashboard/chartsViews"; import DownloadCharts from "../../components/userDashboard/downloadCharts"; import OrdenesCompra from "../../components/userDashboard/OrdenesCompra"; +import { getSesion } from "../../redux/actions/actionsUser"; const Profile = () => { const router = useRouter(); + const dispatch = useDispatch() + useEffect(() => { + dispatch(getSesion()); + + }, [dispatch]) const sesion = useSelector((state) => state.usersData.sesion); console.log(sesion); - - +/* const [sesionProfile, setSesionProfile ] = useState({}) + sesion?.id && setSesionProfile({...sesion}) */ // const userName = useSelector((state) => state.usersData.users); // const projects = useSelector((state) => state.projectsData.projectsFilter); @@ -31,6 +38,9 @@ const Profile = () => { // useEffect(() => { // dispatch(getUserByName(name)); // }, [dispatch]); + const loading = useSelector((state) => state.usersData.loading); + //* Aqui se maneja el loader + if (!sesion?.id) return ; return ( From 7e7595efe179abf72ae767a9c30b93bdd12067a1 Mon Sep 17 00:00:00 2001 From: DracoAlex84 Date: Wed, 25 Oct 2023 18:31:24 -0300 Subject: [PATCH 18/86] 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 3d9ecbde..63e3b62a 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 ad2e130f..71cd82f5 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 2ae83d2c..4d463fff 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 c7126b3c..5dcdcc19 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 361d0158009bbcab19d17a864d7a8c35675a21ea Mon Sep 17 00:00:00 2001 From: Lau Grisanzio <123251122+lauragrisanzio@users.noreply.github.com> Date: Wed, 25 Oct 2023 18:58:47 -0300 Subject: [PATCH 19/86] changes --- .../userDashboard/OrdenesCompra.jsx | 2 +- front/pages/profile/index.js | 63 ++++++++++++++++--- front/redux/types.js | 4 +- server/src/db.js | 12 ++-- 4 files changed, 62 insertions(+), 19 deletions(-) diff --git a/front/components/userDashboard/OrdenesCompra.jsx b/front/components/userDashboard/OrdenesCompra.jsx index 3b53185f..f4385583 100644 --- a/front/components/userDashboard/OrdenesCompra.jsx +++ b/front/components/userDashboard/OrdenesCompra.jsx @@ -85,7 +85,7 @@ const rows = [ ]; const OrdenesCompra = ({id}) => { -console.log(id); +// console.log(id); const dispatch = useDispatch(); diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index c5e06297..6d623660 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -17,17 +17,60 @@ import Example from "../../components/userDashboard/chartsViews"; import DownloadCharts from "../../components/userDashboard/downloadCharts"; import OrdenesCompra from "../../components/userDashboard/OrdenesCompra"; import { getSesion } from "../../redux/actions/actionsUser"; - +import { getProjects } from "../../redux/actions/actions"; +import { + Button, + Modal, + ModalContent, + ModalHeader, + ModalFooter, + useDisclosure, + Link, + Image +} from "@nextui-org/react"; +import { + BarChart, + Bar, + XAxis, + YAxis, + CartesianGrid, + Tooltip, + Legend, + ResponsiveContainer, +} from "recharts"; const Profile = () => { const router = useRouter(); - const dispatch = useDispatch() - useEffect(() => { + const { isOpen, onOpen, onOpenChange } = useDisclosure(); + const dispatch = useDispatch(); + useEffect(() => { dispatch(getSesion()); - - }, [dispatch]) + dispatch(getProjects()); + }, [dispatch]); const sesion = useSelector((state) => state.usersData.sesion); console.log(sesion); + const projects = useSelector((state) => state.projectsData.projects); + console.log(projects); + const projectsByUser = projects.filter( + (p) => Number(p.Users[0]?.id) === 2); //aca va sesion.id + + const viewsByProject = projectsByUser?.map((p) => { + return { + name: p.name, + views: p.views ? p.views :

No se encuentran vistas para este proyecto

+ }; + }); + + const ratingByProject = projectsByUser?.map((p) => { + return { + name: p.name, + rating: p.Ratings[0]?.score ? ( + p.Ratings[0]?.score + ) : ( +

Este proyecto no se encuentra rankeado

+ ), + }; + }); ; /* const [sesionProfile, setSesionProfile ] = useState({}) sesion?.id && setSesionProfile({...sesion}) */ @@ -36,9 +79,7 @@ const Profile = () => { // console.log(userName); // const dispatch = useDispatch(); - // useEffect(() => { - // dispatch(getUserByName(name)); - // }, [dispatch]); + const loading = useSelector((state) => state.usersData.loading); //* Aqui se maneja el loader if (!sesion?.id) return ; @@ -65,7 +106,7 @@ const Profile = () => {
- + @@ -96,6 +137,7 @@ const Profile = () => {

Proyectos

+ {/* */}
{projectsByUser.map((proj) => ( @@ -163,7 +205,8 @@ const Profile = () => { className="mb-4 mr-4 bg-orange-600 rounded-none text-lg font-bold " color="primary" > - {active ? "Activar" : "Desactivar"} + {/* {active ? "Activar" : "Desactivar"} */} + Activar
diff --git a/front/redux/types.js b/front/redux/types.js index 08404e4c..13aa01d3 100644 --- a/front/redux/types.js +++ b/front/redux/types.js @@ -40,10 +40,10 @@ export const RESTORE_USER = "RESTORE_USER" export const PAYMENT_RECORD = "PAYMENT_RECORD" //endpoint - export const ENDPOINT = "http://localhost:3001/"; +// 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/"; +export const ENDPOINT = "https://projunity-production.up.railway.app/"; //payments diff --git a/server/src/db.js b/server/src/db.js index b9ea4582..9388bfa7 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 0190655d6f8c0dce1d28fd98c4019893fb3093ae Mon Sep 17 00:00:00 2001 From: Lau Grisanzio <123251122+lauragrisanzio@users.noreply.github.com> Date: Wed, 25 Oct 2023 20:24:01 -0300 Subject: [PATCH 20/86] profile - faltan comentarios y requests --- .../userDashboard/OrdenesCompra.jsx | 61 +++++----- front/components/userDashboard/OrderDetail.js | 113 +++++++++--------- front/pages/profile/index.js | 5 + front/redux/actions/actions.js | 7 +- front/redux/actions/actionsPayments.js | 9 +- front/redux/reducers/paymentReducer.js | 2 +- front/redux/types.js | 7 +- 7 files changed, 105 insertions(+), 99 deletions(-) diff --git a/front/components/userDashboard/OrdenesCompra.jsx b/front/components/userDashboard/OrdenesCompra.jsx index f4385583..12ca6d0f 100644 --- a/front/components/userDashboard/OrdenesCompra.jsx +++ b/front/components/userDashboard/OrdenesCompra.jsx @@ -85,22 +85,24 @@ const rows = [ ]; const OrdenesCompra = ({id}) => { -// console.log(id); +console.log(id); const dispatch = useDispatch(); - + useEffect(() => { dispatch(getOrder()); }, [dispatch]); - const orders = useSelector((state) => state.paymentData.payments); - console.log(orders); - + const order = useSelector((state) => state.paymentData.payments); + console.log(order); + const orderByuser = order.filter((o) => Number(o.buyer) === Number(id)) + console.log(orderByuser); + const ordersShort = orderByuser.slice(0, 10) //buscar por orden de compra -const [compra, setCompra] = useState(""); -const searchBuy = rows.filter((r) => - r.compra.toUpperCase().includes(compra.toUpperCase()) - ); +// const [compra, setCompra] = useState(""); +// const searchBuy = ordersShort.filter((r) => +// Number(r.id) === Number(compra) +// ); //filtrar por estado de la compra // const [filter, setFilter] = useState([]) @@ -112,7 +114,7 @@ const searchBuy = rows.filter((r) => return (
- - */} + {/* setCompra(e.target.value)} - /> + /> */} {/* */} @@ -136,20 +138,21 @@ const searchBuy = rows.filter((r) =>
{projectsByUser.views}23 45 12
{/* {(column) => ( {column.label} )} */} + FECHA N° COMPRA - N° COMPRA - N° COMPRA - N° COMPRA - N° COMPRA - N° COMPRA - N° COMPRA + ESTADO + PRODUCTO + PRECIO + DETALLES + DESCARGA {/* {(item) => ( @@ -160,17 +163,17 @@ const searchBuy = rows.filter((r) => )} */} - {searchBuy.map((order) => ( + {ordersShort.map((order) => ( - {order.compra} - {order.date} - {order.price} - {order.status} - {order.product} + {order?.createdAt ?order.createdAt.slice(0,10) :

Se desconoce la fecha

}
+ {order?.id} + {order?.status.toUpperCase()} + {order?.product} + ${order?.paymentAmount} - {/* y */} - {/* */} - + {/* */} diff --git a/front/components/userDashboard/OrderDetail.js b/front/components/userDashboard/OrderDetail.js index 3af62367..86a5783f 100644 --- a/front/components/userDashboard/OrderDetail.js +++ b/front/components/userDashboard/OrderDetail.js @@ -1,54 +1,54 @@ import { useState } from "react"; import {Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button, useDisclosure} from "@nextui-org/react"; -const order = [ - { - key: 1, - compra: "2AWERF45", - date: "04/06/2023", - status: "Facturada", - product: "Laravel", - price: "34", - description: "hoola mundo", - desarrollador: "steve jobs", - }, - { - key: 2, - compra: "2AWERF46", - date: "04/06/2023", - status: "Facturada", - product: "Laravel", - price: "34", - description: "hoola mundo", - desarrollador: "steve jobs", - }, - { - key: 3, - compra: "2AWERF47", - date: "04/06/2023", - status: "Facturada", - product: "Laravel", - price: "34", - description: "hoola mundo", - desarrollador: "steve jobs", - }, - { - key: 4, - compra: "2AWERF48", - date: "04/06/2023", - status: "Cancelada", - product: "Laravel", - price: "34", - description: "hoola mundo", - desarrollador: "steve jobs", - }, -]; -const OrderDetail = ({id}) => { +// const order = [ +// { +// key: 1, +// compra: "2AWERF45", +// date: "04/06/2023", +// status: "Facturada", +// product: "Laravel", +// price: "34", +// description: "hoola mundo", +// desarrollador: "steve jobs", +// }, +// { +// key: 2, +// compra: "2AWERF46", +// date: "04/06/2023", +// status: "Facturada", +// product: "Laravel", +// price: "34", +// description: "hoola mundo", +// desarrollador: "steve jobs", +// }, +// { +// key: 3, +// compra: "2AWERF47", +// date: "04/06/2023", +// status: "Facturada", +// product: "Laravel", +// price: "34", +// description: "hoola mundo", +// desarrollador: "steve jobs", +// }, +// { +// key: 4, +// compra: "2AWERF48", +// date: "04/06/2023", +// status: "Cancelada", +// product: "Laravel", +// price: "34", +// description: "hoola mundo", +// desarrollador: "steve jobs", +// }, +// ]; +const OrderDetail = ({id, order}) => { // const router = useRouter(); // const { id } = router.query; - const orderDetail = order.filter((o) =>o.key === Number(id)) + const orderDetail = order.filter((o) =>o.id === Number(id)) const { isOpen, onOpen, onClose } = useDisclosure(); @@ -67,31 +67,34 @@ setSize(size)
- + {(onClose) => ( <> -

- Detalle - Orden de compra N°: {orderDetail[0]?.compra} -

+

Detalle - Orden de compra N°: {orderDetail[0]?.id}

-

Fecha: {orderDetail[0]?.date}

-

Estados: {orderDetail[0]?.status}

-

Desarrollador: {orderDetail[0]?.desarrollador}

+

+ Fecha: + {orderDetail[0]?.createdAt ? ( + orderDetail[0].createdAt.slice(0, 10) + ) : ( +

Se desconoce la fecha

+ )} +

+

Estados: {orderDetail[0]?.status.toUpperCase()}

+

Concepto: {orderDetail[0]?.concept.toUpperCase()}

Producto: {orderDetail[0]?.product}

-

Precio: ${orderDetail[0]?.price}

-

Descripción: {orderDetail[0]?.description}

+

Precio: ${orderDetail[0]?.paymentAmount}

diff --git a/front/components/userDashboard/PDFDownload.js b/front/components/userDashboard/PDFDownload.js index 1c2d5ee3..e9e8d675 100644 --- a/front/components/userDashboard/PDFDownload.js +++ b/front/components/userDashboard/PDFDownload.js @@ -1,5 +1,6 @@ import { jsPDF} from "jspdf"; import "jspdf-autotable"; +// import image from "../../public/PROJUNITY.png"; export const PDFDownload = () => { // Crear un nuevo documento PDF @@ -7,7 +8,8 @@ export const PDFDownload = () => { doc.setFont("helvetica"); doc.setFontSize(30); doc.text("Orden de compra", 145, 20, null, null, "center"); - +// const imgData = image; +// doc.addImage(imgData, "PNG", 15, 40, 148, 210); // Agregar contenido al PDF // doc.text("Orden de compra", 105, 15, 15, null, "center"); @@ -62,5 +64,5 @@ export const PDFDownload = () => { }); // Descargar el PDF - doc.save("Compra.pdf"); + doc.save("OrdenDeCompra.pdf"); }; diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index 4126c563..961027a6 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -58,14 +58,18 @@ const Profile = () => { const projectsByUser = projects.filter( (p) => Number(p.Users[0]?.id) === 2); //aca va sesion.id - - const viewsByProject = projectsByUser?.map((p) => { - return { - name: p.name, - views: p.views ? p.views :

No se encuentran vistas para este proyecto

- }; - }); - + const viewsByProject = projectsByUser?.map((p) => { + return { + name: p.name, + views: p.views ? p.views :

No se encuentran vistas para este proyecto

+ }; + }); + console.log(viewsByProject); + + + const totalViews = viewsByProject.reduce( + (total, item) => total + item.views,0); + const ratingByProject = projectsByUser?.map((p) => { return { name: p.name, @@ -85,7 +89,7 @@ const Profile = () => { // const dispatch = useDispatch(); - const loading = useSelector((state) => state.usersData.loading); + // const loading = useSelector((state) => state.usersData.loading); //* Aqui se maneja el loader if (!sesion?.id) return ; @@ -111,7 +115,7 @@ const Profile = () => {
- + @@ -322,7 +326,7 @@ const Profile = () => {

Historial de compras

- +
diff --git a/front/public/PROJUNITY.png b/front/public/PROJUNITY.png new file mode 100644 index 0000000000000000000000000000000000000000..87ad17268f20e3157179c3f6b89306527c6a83bb GIT binary patch literal 24992 zcmeFZc{J32{P_Ex8OAmkgqdt(7s?n!*=9y|vX_JgQ%Pk>*=6k8q#??ZUD<_Ji7eS# zY-KCi(~zRFrR~0^&-dPQ@4vr$|GDS%XB-fc8=gSxu5y5mmD2j=O)&)t#ez|6;%prHpPgX&UOokt9%51uXMn2pB>~3 zEh|P9D3U!M>P}iaapfdy+Z6oj8M|{r<+)bjUiYI;PJhFWIgPwq!{tVeR{Z^uDl0i` zh%j zn``nfg-3i^p1l8c2M*m5r0${^9M?=8ymrLQ?r)gz>}o5Qer|oKd)sCA+8c$sznY;H z={Vt6HwRw|ugXLw1lQ8$1GB~A#35T8$>dZ=$@=;2je~RSOVVFD;F}H=GuxR{elSWz z@lIWi*kKv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z(y9MQ6R2alpzC=51lP{Do_4Cc+er%ayM`V30zP*QWk^rKQM*=F5BJxbcUxoa-D7?| za?{i)DDP_qy*sURqz3GI!YHrqasF!K9g9}HrbVbto26LhX(Wv(Psx_Ht(jQg1))wk zpboEs+gT{qVpaCL!_!$7av|Y#?7nVQ&?oDx)tf6R`PsNJ&N}O9if=7d*x_v z;)qg}3-TTp_=$ppypu{GR;t%Z7WXDpIvt4$!d+u;_<)t?PwD-pCB?#wm42oo$3Uyk6vR1Qk9S2lubm#r} zy_UK-k%hHB2uqrr57j;`Xbm3w#`;%~3S#(Vv5I5;hI84^X z9jM38zY{U%Z!Ex5$0pe?@CUexw0{NB!1jBz%(=QrJ^5^qBs$sofFkYqud!QR17{gZ zW4y`?7l<24vXE-cpc4bxvYjPvI)13NN%&zz8A$#pc{spj{6KCt@JM4m6!d*j*wu^C zO5*GYZdZxNSUt%gIVHK6fB@(hb;*0+ygCKRr%to*=F~s)T2D_TZ63f91U61V% z72_(scOs6&+>Mo5N2c(ikz;U!Pi)}#hs)YK%EN|9rADlu>Yb`<>a<-V=62+MhRBB~ z^MEV-^RU_R16?M&t>atir5A5CL}-@xi^T&O0oa1|dkj#`Wi3iP;-l;~bWxLO%2_WT z7{-T3Nz_Hja@3iCUmzu(*>h5j@w#Yq6YhQkq)FMt`nz7OxSN1!GBSqMY@3?_Qc^a- zjHy%Q>Qsw}V2^MfQ-b}{b*}x!gU6>ow!`U#jykA Date: Thu, 26 Oct 2023 00:35:33 -0300 Subject: [PATCH 22/86] 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 62e4cc5a..ee65c3e3 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 23/86] 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 07d16110..ca917a70 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 24/86] 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 90adbebf..f2e5ed8a 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 25/86] 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 68a125d5..f21a383e 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 26/86] 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 5ff56638..6ee7b8cf 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 27/86] 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 e95756be..bf1b9a92 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 28/86] 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 1991afb9..224c2bbc 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 29/86] 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 d11877c7..6d1c5b6f 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 30/86] 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 ca917a70..98e16e74 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 31/86] 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 98e16e74..fbe1ceaf 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 32/86] 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 fbe1ceaf..98e16e74 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 33/86] 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 98e16e74..ba3a1d59 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 34/86] 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 def5f3ca..1d98ee15 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 35/86] 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 4ada1e3f..eddf5f65 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 36/86] 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 1d98ee15..499e16c1 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 37/86] 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 4d463fff..9d146861 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 38/86] 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 71cd82f5..d7b0c6fe 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 39/86] 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 656d1d56..7aa82c3d 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 40/86] 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 11fbf7d8..974d78df 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 8eaa86fcac72f3a25bd51595451fa8e4464501aa Mon Sep 17 00:00:00 2001 From: Gustavo Rodolfo Paz Date: Thu, 26 Oct 2023 10:02:01 -0300 Subject: [PATCH 41/86] 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 7aa82c3d..dc990a26 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 42/86] 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 dc990a26..87d074ab 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 43/86] 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 9d146861..f604309f 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 44/86] 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 f604309f..b5c33923 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 45/86] 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 b5c33923..29c4c328 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 46/86] 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 29c4c328..df3b8a1c 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 47/86] 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 499e16c1..42f92a69 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 48/86] 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 f21a383e..5108045f 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 49/86] 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 224c2bbc..f7654dff 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 50/86] 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 df3b8a1c..5a94da40 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 c4d41bd3cc982e79c87f67e86e782c29f04e3385 Mon Sep 17 00:00:00 2001 From: Lau Grisanzio <123251122+lauragrisanzio@users.noreply.github.com> Date: Thu, 26 Oct 2023 19:35:15 -0300 Subject: [PATCH 51/86] agregue borrado logico --- front/components/userDashboard/ButtonA.jsx | 59 ++++++ front/components/userDashboard/Buttons.jsx | 63 ++++++ .../components/userDashboard/analDashUser.jsx | 73 ++++++- front/components/userDashboard/analitycs.jsx | 27 +++ front/pages/profile/analitycs.js | 32 --- front/pages/profile/index.js | 110 +++++----- front/redux/actions/actions.js | 34 ++++ front/redux/reducers/projectsReducer.js | 19 +- front/redux/types.js | 7 +- server/index.js | 2 +- server/src/routes/index.js | 2 +- server/src/services/projects.js | 189 +++++++++--------- 12 files changed, 437 insertions(+), 180 deletions(-) create mode 100644 front/components/userDashboard/ButtonA.jsx create mode 100644 front/components/userDashboard/Buttons.jsx create mode 100644 front/components/userDashboard/analitycs.jsx delete mode 100644 front/pages/profile/analitycs.js diff --git a/front/components/userDashboard/ButtonA.jsx b/front/components/userDashboard/ButtonA.jsx new file mode 100644 index 00000000..13333261 --- /dev/null +++ b/front/components/userDashboard/ButtonA.jsx @@ -0,0 +1,59 @@ +import { useRouter } from "next/router"; +// import ButtonEdit from "../../components/userDashboard/buttonEdit"; +import { useDispatch, useSelector } from "react-redux"; +import { useEffect, useState } from "react"; + +import LayoutUser from "../layout/layoutUser"; +import Loader from "../layout/loader"; + +import Head from "next/head"; + +import ProjDashUser from "./projDashUser"; +import ButtonCreate from "./buttonCreateProj"; +import ButtonPromotion from "./buttonPromotion"; +import ButtonRequest from "./buttonRequest"; +import Posts from "./posts"; +import Example from "./chartsViews"; +import DownloadCharts from "./downloadCharts"; +import OrdenesCompra from "./OrdenesCompra"; +import { getSesion } from "../../redux/actions/actionsUser"; +import { restoreProjects } from "../../redux/actions/actions"; +// import { getOrder } from "../../redux/actions/actionsPayments"; +import { + Button, + Modal, + ModalContent, + ModalHeader, + ModalFooter, + useDisclosure, + Link, + Image, +} from "@nextui-org/react"; +import Swal from "sweetalert2"; + +const ButtonA = ({ id }) => { + console.log(id); + + const dispatch = useDispatch() + + + return ( +
+ + + {/* + + )} + + */} +
+ ); +}; + +export default ButtonA; diff --git a/front/components/userDashboard/Buttons.jsx b/front/components/userDashboard/Buttons.jsx new file mode 100644 index 00000000..dc96ba70 --- /dev/null +++ b/front/components/userDashboard/Buttons.jsx @@ -0,0 +1,63 @@ +import { useDispatch, useSelector } from "react-redux"; +import { useEffect, useState } from "react"; + +import { restoreProjects } from "../../redux/actions/actions"; +import { deleteProjects } from "../../redux/actions/actions"; + +import {Button} from "@nextui-org/react"; +import Swal from "sweetalert2"; + +const Buttons = ({ id }) => { + console.log(id); + + const dispatch = useDispatch() + const [activeButton, setActiveButton] = useState(false); + const [desactiveButton, setDesactiveButton] = useState(true); + + const active = () => { + dispatch(restoreProjects(id)); + Swal.fire({ + icon: "success", + title: "Proyecto activado con exito!", + showConfirmButton: true, + timer: 3500, + }); +activeButton + setActiveButton(false); + setDesactiveButton(true); + }; + const desactive = () => { + dispatch(deleteProjects(id)) + Swal.fire({ + icon: "success", + title: "Proyecto desactivado con exito!", + showConfirmButton: true, + timer: 3500, + }) + setActiveButton(true); + setDesactiveButton(false); + } + + + + return ( +
+ + +
+ ); +}; + +export default Buttons; diff --git a/front/components/userDashboard/analDashUser.jsx b/front/components/userDashboard/analDashUser.jsx index 33eeca87..335ff324 100644 --- a/front/components/userDashboard/analDashUser.jsx +++ b/front/components/userDashboard/analDashUser.jsx @@ -1,11 +1,76 @@ -import TableTotalProj from "./tableProjTotals"; +import { + Table, + TableHeader, + TableColumn, + TableBody, + TableRow, + TableCell, + getKeyValue, + Spinner, +} from "@nextui-org/react"; -const AnalDashUser = () => { +const AnalDashUser = ({ proj }) => { return (
-

Proyectos Totales

- +
23{totalViews} 45 12
+ + + Estado + + + Proyectos + + + Vistas + + + Descargas + + + Ganancias + + + Pagos + + + Clasificación + + + } + > + + + Activo + + Laravel + 100 + 39 + $9 + $50 + 7/10 + + + + Activo + + Rick and Morty + 240 + 50 + $200 + $250 + 9/10 + + +
); }; diff --git a/front/components/userDashboard/analitycs.jsx b/front/components/userDashboard/analitycs.jsx new file mode 100644 index 00000000..c5910925 --- /dev/null +++ b/front/components/userDashboard/analitycs.jsx @@ -0,0 +1,27 @@ +import LayoutUser from "../layout/layoutUser.js"; +import Head from "next/head"; +import ChartsAnalitycs from "./chartsAnalitycs.jsx"; +import FilterAnalitycs from "./filterAnalitycs.jsx"; +import AnalDashUser from "./analDashUser.jsx"; +import { useSelector } from "react-redux"; + +const Analitycs = ({ proj }) => { + console.log(proj); + const sesion = useSelector((state) => state.usersData.sesion); + console.log(sesion); + return ( +
+

Estadisticas

+
+
+ {/* */} + + +
+

Proyectos mayor rendimiento por promoción

+

Solicitudes con mayor rendimiento

+
+ ); +}; + +export default Analitycs; diff --git a/front/pages/profile/analitycs.js b/front/pages/profile/analitycs.js deleted file mode 100644 index dec7c5ba..00000000 --- a/front/pages/profile/analitycs.js +++ /dev/null @@ -1,32 +0,0 @@ -import LayoutUser from "../../components/layout/layoutUser.js"; -import Head from "next/head"; -import ChartsAnalitycs from "../../components/userDashboard/chartsAnalitycs.jsx"; -import FilterAnalitycs from "../../components/userDashboard/filterAnalitycs.jsx"; -import AnalDashUser from "../../components/userDashboard/analDashUser.jsx"; -import { useSelector } from "react-redux"; - -const Analitycs = () => { - const sesion = useSelector((state) => state.usersData.sesion); - console.log(sesion); - return ( - - - ProjUnity | Analiticas {/* {sesion.name} */} - - -
-

Estadisticas

-
-
- - - -
-

Proyectos mayor rendimiento por promoción

-

Solicitudes con mayor rendimiento

-
-
- ); -}; - -export default Analitycs; diff --git a/front/pages/profile/index.js b/front/pages/profile/index.js index 961027a6..59df6a12 100644 --- a/front/pages/profile/index.js +++ b/front/pages/profile/index.js @@ -17,7 +17,7 @@ import Example from "../../components/userDashboard/chartsViews"; import DownloadCharts from "../../components/userDashboard/downloadCharts"; import OrdenesCompra from "../../components/userDashboard/OrdenesCompra"; import { getSesion } from "../../redux/actions/actionsUser"; -import { getProjects } from "../../redux/actions/actions"; +import { getProjects, deleteProjects } from "../../redux/actions/actions"; // import { getOrder } from "../../redux/actions/actionsPayments"; import { Button, @@ -27,7 +27,7 @@ import { ModalFooter, useDisclosure, Link, - Image + Image, } from "@nextui-org/react"; import { BarChart, @@ -39,37 +39,45 @@ import { Legend, ResponsiveContainer, } from "recharts"; +import Analitycs from "../../components/userDashboard/analitycs"; +import Buttons from "../../components/userDashboard/Buttons"; +import ButtonA from "../../components/userDashboard/ButtonA"; const Profile = () => { const router = useRouter(); - const { isOpen, onOpen, onOpenChange } = useDisclosure(); + const { isOpen, onOpen, onOpenChange } = useDisclosure(); + const dispatch = useDispatch(); useEffect(() => { dispatch(getSesion()); dispatch(getProjects()); - }, [dispatch]); + const sesion = useSelector((state) => state.usersData.sesion); console.log(sesion); const projects = useSelector((state) => state.projectsData.projects); - console.log(projects); + + const projectsByUser = projects?.filter((p) => Number(p.Users[0]?.id) === 2); //aca va sesion.id + // const idP = projectsByUser.filter(p => p.id); + console.log(projectsByUser); + const viewsByProject = projectsByUser?.map((p) => { + return { + name: p.name, + views: p.views ? ( + p.views + ) : ( +

No se encuentran vistas para este proyecto

+ ), + }; + }); + console.log(viewsByProject); + const totalViews = viewsByProject.reduce( + (total, item) => total + item.views, + 0 + ); - const projectsByUser = projects.filter( - (p) => Number(p.Users[0]?.id) === 2); //aca va sesion.id - const viewsByProject = projectsByUser?.map((p) => { - return { - name: p.name, - views: p.views ? p.views :

No se encuentran vistas para este proyecto

- }; - }); - console.log(viewsByProject); - - - const totalViews = viewsByProject.reduce( - (total, item) => total + item.views,0); - const ratingByProject = projectsByUser?.map((p) => { return { name: p.name, @@ -79,8 +87,8 @@ const Profile = () => {

Este proyecto no se encuentra rankeado

), }; - }); ; -/* const [sesionProfile, setSesionProfile ] = useState({}) + }); + /* const [sesionProfile, setSesionProfile ] = useState({}) sesion?.id && setSesionProfile({...sesion}) */ // const userName = useSelector((state) => state.usersData.users); @@ -88,9 +96,11 @@ const Profile = () => { // console.log(userName); // const dispatch = useDispatch(); - // const loading = useSelector((state) => state.usersData.loading); //* Aqui se maneja el loader + + + if (!sesion?.id) return ; return ( @@ -130,15 +140,15 @@ const Profile = () => { Proyectos
- {/*

- Promociones -

*/}

- Solicitudes + Estadísticas

-

+ {/*

+ Solicitudes +

*/} + {/*

Posts -

+

*/}

Historial de Compras

@@ -147,8 +157,8 @@ const Profile = () => {

Proyectos

{/* */} -
-
+
+
{projectsByUser.map((proj) => (
@@ -160,7 +170,7 @@ const Profile = () => { // object-fit="cover" />
-
+

{proj.name}

@@ -168,7 +178,7 @@ const Profile = () => {
@@ -202,21 +212,27 @@ const Profile = () => {
- + + {/* - + */} + {/* + {active ? "Activar" : "Desactivar"} */} + {/* Desactivar + */}
@@ -294,7 +310,11 @@ const Profile = () => {
+
+ +
{/* +

Promociones

@@ -312,18 +332,18 @@ const Profile = () => {
*/} -
+ {/*

Solicitudes

-
-
+
*/} + {/*

Posts

-
+
*/}

Historial de compras

diff --git a/front/redux/actions/actions.js b/front/redux/actions/actions.js index b49272ec..f462a425 100644 --- a/front/redux/actions/actions.js +++ b/front/redux/actions/actions.js @@ -13,6 +13,7 @@ import { LOGIN, GET_PREMIUM_PROJECT, ENDPOINT, + DELETE_PROJECTS } from "../types"; const endpoint = ENDPOINT; @@ -192,3 +193,36 @@ export const updateProject = (data, id) => { } }; }; + +export const deleteProjects = (idP) => { + console.log(idP); + return async (dispatch) => { + try { + const { data } = await axios.delete(`${endpoint}projects/${idP}`); + + return dispatch({ type: DELETE_PROJECTS, payload: data }); + } catch (error) { + /* return dispatch({ + type: SET_ALERT, + payload: { type: "error", msg: error.message }, + }); */ + console.log(error.message); + } + }; +}; + +export const restoreProjects = (idP) => { + return async (dispatch) => { + try { + const { data } = await axios.put(`${endpoint}projects/restore/${idP}`); + + return dispatch({ type: DELETE_PROJECTS, payload: data }); + } catch (error) { + /* return dispatch({ + type: SET_ALERT, + payload: { type: "error", msg: error.message }, + }); */ + console.log(error.message); + } + }; +}; diff --git a/front/redux/reducers/projectsReducer.js b/front/redux/reducers/projectsReducer.js index 2ba25aa0..ec51c9ff 100644 --- a/front/redux/reducers/projectsReducer.js +++ b/front/redux/reducers/projectsReducer.js @@ -9,7 +9,9 @@ import { FILTERS, ORDER_CATEGORIES, GET_PROJECTS_BY_NAME, - GET_PREMIUM_PROJECT + GET_PREMIUM_PROJECT, + DELETE_PROJECTS, + RESTORE_PROJECTS } from "../types"; const initialState = { @@ -21,6 +23,7 @@ const initialState = { test: {}, alert: {}, detail: [], + projectsDesactive: [], }; const projectsReducer = (state = initialState, action) => { @@ -73,7 +76,7 @@ const projectsReducer = (state = initialState, action) => { case GET_PREMIUM_PROJECT: return { ...state, - premium: action.payload.sort((a, b) => b.views - a.views).slice(0,3), + premium: action.payload.sort((a, b) => b.views - a.views).slice(0, 3), }; //! seccion de filtros proyectos @@ -120,6 +123,18 @@ const projectsReducer = (state = initialState, action) => { : true) ), }; + case DELETE_PROJECTS: + return { + ...state, + projectsDesactive: action.payload, + }; + + case RESTORE_PROJECTS: + return { + ...state, + projectsDesactive: action.payload, + }; + default: return state; } diff --git a/front/redux/types.js b/front/redux/types.js index 194b4c64..4a91d1af 100644 --- a/front/redux/types.js +++ b/front/redux/types.js @@ -9,8 +9,9 @@ export const FILTERS = "FILTERS"; export const ORDER_CATEGORIES = "ORDER_CATEGORIES"; export const FILTER_CLEAR = "FILTER_CLEAR"; export const GET_PREMIUM_PROJECT = "GET_PREMIUM_PROJECT"; - +export const DELETE_PROJECTS = "DELETE_PROJECTS"; export const GET_PROJECTS_BY_NAME = "GET_PROJECTS_BY_NAME"; +export const RESTORE_PROJECTS = "RESTORE_PROJECTS"; /* export const GET_PROJECTS_BY_NAME = "GET_PROJECTS_BY_NAME"; */ /* export const GET_USER_BY_ID = "GET_USER_BY_ID"; */ @@ -40,8 +41,8 @@ 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/index.js b/server/index.js index b2d44704..6e8d98ba 100644 --- a/server/index.js +++ b/server/index.js @@ -34,7 +34,7 @@ const { } = require("./src/db"); const { createUser } = require("./src/services/Users"); conn - .sync({ force: true }) + .sync({ force: true }) .then(() => { server.listen(PORT, async () => { await UserTypes.bulkCreate(userTypes); diff --git a/server/src/routes/index.js b/server/src/routes/index.js index 5108045f..d2609778 100644 --- a/server/src/routes/index.js +++ b/server/src/routes/index.js @@ -67,7 +67,7 @@ router .route("/projects/:id") .get(Controller.getProjectsID) .put(Controller.putProjects) - .delete( Controller.deleteProject); + .delete(Controller.deleteProject); router.put('/projects/restore/:id', Controller.restoreProject) diff --git a/server/src/services/projects.js b/server/src/services/projects.js index 393e23d3..696a8b05 100644 --- a/server/src/services/projects.js +++ b/server/src/services/projects.js @@ -16,74 +16,73 @@ const ProjectServices = { try { const { name, category, tag, price, rating, username, id } = queryParams; let condition = {}; - id + id ? (condition = { ...condition, - project: - {...condition.project, id: id} - }) + project: { ...condition.project, id: id }, + }) : null; name ? (condition = { - ...condition, - project: { - name: { [Op.iLike]: `%${name}%` }, - [Op.or]: [{ name: { [Op.iLike]: `${name}%` } }], - }, - }) + ...condition, + project: { + name: { [Op.iLike]: `%${name}%` }, + [Op.or]: [{ name: { [Op.iLike]: `${name}%` } }], + }, + }) : null; tag ? (condition = { - ...condition, - tag: { - name: { [Op.iLike]: `%${tag}%` }, - [Op.or]: [{ name: { [Op.iLike]: `${tag}%` } }], - }, - }) + ...condition, + tag: { + name: { [Op.iLike]: `%${tag}%` }, + [Op.or]: [{ name: { [Op.iLike]: `${tag}%` } }], + }, + }) : null; category ? (condition = { - ...condition, - category: { - name: { [Op.iLike]: `%${category}%` }, - [Op.or]: [{ name: { [Op.iLike]: `${category}%` } }], - }, - }) + ...condition, + category: { + name: { [Op.iLike]: `%${category}%` }, + [Op.or]: [{ name: { [Op.iLike]: `${category}%` } }], + }, + }) : null; price ? (condition = { - ...condition, - project: { - ...condition.project, - price: { - [Op.or]: { [Op.lt]: price, [Op.eq]: price }, - }, + ...condition, + project: { + ...condition.project, + price: { + [Op.or]: { [Op.lt]: price, [Op.eq]: price }, }, - }) + }, + }) : null; rating - ? (condition = { + ? (condition = { ...condition, rating: { - score:{ - [Op.or]:{ + score: { + [Op.or]: { [Op.lt]: rating, - [Op.eq]: rating , - } + [Op.eq]: rating, + }, }, }, }) - : null; - username - ? (condition = { - ...condition, - users: { - name: { [Op.iLike]: `%${username}%` }, - [Op.or]: [{ name: { [Op.iLike]: `${username}%` } }] - } - }) - : null; - + : null; + username + ? (condition = { + ...condition, + users: { + name: { [Op.iLike]: `%${username}%` }, + [Op.or]: [{ name: { [Op.iLike]: `${username}%` } }], + }, + }) + : null; + const projectsFilter = await Projects.findAll({ include: [ { @@ -102,7 +101,7 @@ const ProjectServices = { model: Ratings, attributes: ["score", "comment"], where: condition.rating, - through: { attributes:[] } , + through: { attributes: [] }, }, { model: Comments, @@ -117,10 +116,17 @@ const ProjectServices = { }, { model: Users, - attributes: ['id','name','email','githubUser','twitterUser','linkedinUser'], + attributes: [ + "id", + "name", + "email", + "githubUser", + "twitterUser", + "linkedinUser", + ], where: condition.users, - through: {attributes: []} - } + through: { attributes: [] }, + }, ], where: condition.project, }); @@ -152,7 +158,7 @@ const ProjectServices = { !price || !shortDescription || !image || - /* !commentsAllowed || */ + /* !commentsAllowed || */ !status || !category || !tags || @@ -172,7 +178,7 @@ const ProjectServices = { price: parseFloat(price), visibility: visibility /* === "true" ? true : false */, shortDescription, - image : uploadedImage.url, + image: uploadedImage.url, views: 0, commentsAllowed: commentsAllowed /* === "true" ? true : false */, status, @@ -271,46 +277,47 @@ const ProjectServices = { } }, + getDeletedProjects: async function () { try { - const deletedProjects = await Projects.findAll({ - where: { deletedAt: 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; - } -}, + const deletedProjects = await Projects.findAll({ + where: { deletedAt: 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); @@ -318,13 +325,11 @@ const ProjectServices = { throw new Error("Project not found"); } await project.update({ deletedAt: false }); - return { message: 'Project restored successfully' }; + return { message: "Project restored successfully" }; } catch (error) { throw new Error(error.message); } }, - - }; module.exports = ProjectServices; From 3b6f26f8c0d8c0eceaf7482990873992e934bebb Mon Sep 17 00:00:00 2001 From: Lau Grisanzio <123251122+lauragrisanzio@users.noreply.github.com> Date: Thu, 26 Oct 2023 19:42:45 -0300 Subject: [PATCH 52/86] vuelve a funcionar historial de compras --- front/components/userDashboard/OrdenesCompra.jsx | 8 ++++---- front/pages/profile/index.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/front/components/userDashboard/OrdenesCompra.jsx b/front/components/userDashboard/OrdenesCompra.jsx index cde3d6d7..123dcd0b 100644 --- a/front/components/userDashboard/OrdenesCompra.jsx +++ b/front/components/userDashboard/OrdenesCompra.jsx @@ -84,8 +84,8 @@ const rows = [ }, ]; -const OrdenesCompra = ({id, projects}) => { -console.log(id); +const OrdenesCompra = ({name, projects}) => { +console.log(name); const dispatch = useDispatch(); @@ -95,7 +95,7 @@ console.log(id); const order = useSelector((state) => state.paymentData.payments); console.log(order); - const orderByuser = order.filter((o) => Number(o.buyer) === Number(id)) + const orderByuser = order.filter((o) => o.buyer.toUpperCase() === name.toUpperCase()) console.log(orderByuser); const ordersShort = orderByuser.slice(0, 10) @@ -113,7 +113,7 @@ console.log(id); return ( -
+
{/*