diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index 531ec5da..d5d6a973 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -297,7 +297,8 @@ app.post('/group/add', async (req, res) => { } const newGroup = new Group({ name: name, - members: [username] }); + members: [username], + createdAt:Date.now() }); await newGroup.save(); res.json({ message: 'Group created successfully' }); diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index 5b23eddc..f609cabe 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -221,7 +221,7 @@ "errorPrefix": "Error: ", "joinable": "Groups you can join", "join": "Join group", - "noGroups": "There are no groups available to join." + "nogroups": "There are no groups available to join." }, "groupsTable": { "groupName": "Group name", diff --git a/webapp/src/locales/es.json b/webapp/src/locales/es.json index 9b050c38..77ef1f57 100644 --- a/webapp/src/locales/es.json +++ b/webapp/src/locales/es.json @@ -221,7 +221,7 @@ "errorPrefix": "Error: ", "joinable": "Grupos a los que puedes unirte", "join": "Unirse al grupo", - "noGroups": "No hay grupos disponibles para unirse." + "nogroups": "No hay grupos a los que puedas unirte." }, "groupsTable": { "groupName": "Nombre del grupo", diff --git a/webapp/src/pages/Social/GroupDetails.js b/webapp/src/pages/Social/GroupDetails.js index d3c3b3be..ab566a5a 100644 --- a/webapp/src/pages/Social/GroupDetails.js +++ b/webapp/src/pages/Social/GroupDetails.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; -import axios from 'axios'; import { Container, Box, Text, Heading, Table, Thead, Tbody, Tr, Th, Td, Avatar, Link } from '@chakra-ui/react'; import Nav from "../../components/Nav/Nav.js"; import Footer from "../../components/Footer/Footer.js"; @@ -9,39 +8,71 @@ import { useTranslation } from "react-i18next"; const GroupDetails = () => { const { t } = useTranslation(); const [group, setGroup] = useState(null); + const [error, setError] = useState(null); const { groupName } = useParams(); const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; const navigate = useNavigate(); useEffect(() => { - const fetchGroupDetails = async () => { - try { - const response = await axios.get(`${apiEndpoint}/group/${encodeURIComponent(groupName)}`); - setGroup(response.data.group); - } catch (error) { - console.error('Error fetching group details:', error); - } - }; - fetchGroupDetails(); - }, [groupName]); + }, []); + + const fetchGroupDetails = async () => { + try { + const response = await fetch(`${apiEndpoint}/group/${encodeURIComponent(groupName)}`); + if (!response.ok) { + throw new Error('Network response was not ok'); + } + const data = await response.json(); + setGroup(data.group); + setError(null); + } catch (error) { + setError(error); + console.error("Error al obtener los detalles del grupo:", error); + } + }; + const redirectToProfile = (username) => { navigate(`/perfil?user=${username}`); }; + if (error) { + return ( + <> +