Skip to content

Commit

Permalink
Ya va el perfil de amigos
Browse files Browse the repository at this point in the history
  • Loading branch information
CANCI0 committed Apr 26, 2024
1 parent 474fd49 commit f18938b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gatewayservice/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ paths:
get:
summary: Get User Information
parameters:
- in: query
- in: param
name: username
schema:
type: string
Expand Down
13 changes: 5 additions & 8 deletions webapp/src/components/Profile/Profile.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -45,7 +42,7 @@ const Perfil = () => {
<>
{userData && (
<>
<Avatar name={user} />
<Avatar name={user.username} />
<Text justifyContent={"center"}>
<strong>{t('components.profile.name')}</strong> {userData.username}
</Text>
Expand All @@ -56,7 +53,7 @@ const Perfil = () => {
<Heading as="h2" size="md">
{t('components.profile.recentGames')}
</Heading>
<Box overflowX={"scroll"} width={'100%'}>
<Box overflowX={{ base: "scroll", lg: "auto" }} width={'100%'}>
{ userData.games && userData.games.length > 0 ? (
<Table variant="simple">
<Thead>
Expand Down Expand Up @@ -95,5 +92,5 @@ const Perfil = () => {
);
};

export default Perfil;
export default Profile;

4 changes: 3 additions & 1 deletion webapp/src/pages/Perfil/Perfil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<Nav />
<Profile />
<Profile username={username.username}/>
<Footer />
</>
);
Expand Down
2 changes: 0 additions & 2 deletions webapp/src/pages/Social/FriendsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ const FriendList = () => {
return response.json();
})
.then((data) => {
console.log(data);
console.log(data.friends);
setFriends(data.friends);
setIsLoading(false);
})
Expand Down

0 comments on commit f18938b

Please sign in to comment.