From dfd25335058277ebbcfbc43466109bf93cafa3df Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Fri, 26 Apr 2024 22:53:31 +0200 Subject: [PATCH] Perfil desparametrizado, ya funcionan los perfiles de amigos --- webapp/src/App.js | 2 +- webapp/src/App.test.js | 2 +- webapp/src/components/Nav/Nav.js | 2 +- webapp/src/components/Profile/Profile.js | 6 ++++-- webapp/src/pages/Perfil/Perfil.js | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/webapp/src/App.js b/webapp/src/App.js index b19050dd..3c7c44ac 100644 --- a/webapp/src/App.js +++ b/webapp/src/App.js @@ -48,7 +48,7 @@ function App() { } /> } /> - } /> + } /> } /> } /> diff --git a/webapp/src/App.test.js b/webapp/src/App.test.js index df54d25c..d50ea5ec 100644 --- a/webapp/src/App.test.js +++ b/webapp/src/App.test.js @@ -137,7 +137,7 @@ describe("Nav Component", () => { const perfilButton = screen.getByText("Mi perfil"); fireEvent.click(perfilButton); - expect(window.location.pathname).toBe("/perfil/testuser"); + expect(window.location.pathname).toBe("/perfil"); }); test("navigates to /sobre when Sobre nosotros button is clicked", () => { diff --git a/webapp/src/components/Nav/Nav.js b/webapp/src/components/Nav/Nav.js index 3a14fb6c..7b00d446 100644 --- a/webapp/src/components/Nav/Nav.js +++ b/webapp/src/components/Nav/Nav.js @@ -246,7 +246,7 @@ const Nav = () => { - handleNavigate(`/perfil/${username}`)}> + handleNavigate("/perfil")}> {t("components.nav.myprofile")} handleNavigate("/history")}> diff --git a/webapp/src/components/Profile/Profile.js b/webapp/src/components/Profile/Profile.js index 5e553a22..a7ffa5f0 100644 --- a/webapp/src/components/Profile/Profile.js +++ b/webapp/src/components/Profile/Profile.js @@ -10,8 +10,10 @@ const Profile = (user) => { const { t } = useTranslation(); + const username = (user && user.username) || localStorage.getItem("username"); + useEffect(() => { - fetch(gatewayUrl + `/userInfo/${user.username}`) + fetch(gatewayUrl + `/userInfo/${username}`) .then((response) => response.json()) .then((data) => { setUserData(data); @@ -42,7 +44,7 @@ const Profile = (user) => { <> {userData && ( <> - + {t('components.profile.name')} {userData.username} diff --git a/webapp/src/pages/Perfil/Perfil.js b/webapp/src/pages/Perfil/Perfil.js index d0640e1c..4379c9c5 100644 --- a/webapp/src/pages/Perfil/Perfil.js +++ b/webapp/src/pages/Perfil/Perfil.js @@ -9,7 +9,7 @@ const Perfil = () => { return ( <>