From f18938bebb48826dedd942a7f761f7c82125ca2a Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Fri, 26 Apr 2024 21:31:49 +0200 Subject: [PATCH 1/6] Ya va el perfil de amigos --- gatewayservice/openapi.yaml | 2 +- webapp/src/components/Profile/Profile.js | 13 +++++-------- webapp/src/pages/Perfil/Perfil.js | 4 +++- webapp/src/pages/Social/FriendsList.js | 2 -- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/gatewayservice/openapi.yaml b/gatewayservice/openapi.yaml index a74fcb42..8c1ae9fc 100644 --- a/gatewayservice/openapi.yaml +++ b/gatewayservice/openapi.yaml @@ -102,7 +102,7 @@ paths: get: summary: Get User Information parameters: - - in: query + - in: param name: username schema: type: string diff --git a/webapp/src/components/Profile/Profile.js b/webapp/src/components/Profile/Profile.js index c4816a6c..5e553a22 100644 --- a/webapp/src/components/Profile/Profile.js +++ b/webapp/src/components/Profile/Profile.js @@ -1,20 +1,17 @@ import { Box, VStack, Heading, Text, Center, Spinner, Table, Thead, Tbody, Tr, Th, Td, Avatar } from "@chakra-ui/react"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { useParams } from "react-router-dom"; -const Perfil = () => { +const Profile = (user) => { const gatewayUrl = process.env.REACT_APP_API_ENDPOINT || "http://localhost:8000"; const [userData, setUserData] = useState(null); const [loading, setLoading] = useState(true); - const params = useParams(); - const user = params.user || localStorage.getItem("username"); const [error, setError] = useState(null); const { t } = useTranslation(); useEffect(() => { - fetch(gatewayUrl + `/userInfo/${encodeURIComponent(user)}`) + fetch(gatewayUrl + `/userInfo/${user.username}`) .then((response) => response.json()) .then((data) => { setUserData(data); @@ -45,7 +42,7 @@ const Perfil = () => { <> {userData && ( <> - + {t('components.profile.name')} {userData.username} @@ -56,7 +53,7 @@ const Perfil = () => { {t('components.profile.recentGames')} - + { userData.games && userData.games.length > 0 ? ( @@ -95,5 +92,5 @@ const Perfil = () => { ); }; -export default Perfil; +export default Profile; diff --git a/webapp/src/pages/Perfil/Perfil.js b/webapp/src/pages/Perfil/Perfil.js index 3b163a05..d0640e1c 100644 --- a/webapp/src/pages/Perfil/Perfil.js +++ b/webapp/src/pages/Perfil/Perfil.js @@ -4,10 +4,12 @@ import Footer from "../../components/Footer/Footer.js"; import Profile from "../../components/Profile/Profile.js"; const Perfil = () => { + const username = localStorage.getItem("username"); + return ( <>