Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Manueluz committed Apr 27, 2024
1 parent aac248e commit 0efcdae
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
17 changes: 12 additions & 5 deletions webapp/src/components/friends/Friend.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
import { getUsers, getCurrentUser } from "../../services/user.service";
import { acceptRequest, getFriends, getRequests, sendRequest } from "../../services/friends.service";
import {Footer} from '../footer/Footer';
import Swal from 'sweetalert2';

export const Friends = () => {
const { t } = useTranslation();
Expand All @@ -32,7 +33,13 @@ export const Friends = () => {

const sendFriendRequest = () => {
if(selectedUser && selectedUser.id)
sendRequest(localStorage.getItem("token"), selectedUser.id);
sendRequest(localStorage.getItem("token"), selectedUser.id).then(() => {
Swal.fire(
`${t('Friends.success')}`,
`${t('Friends.reqmsg')}`,
'success'
)
});
}

const updateFriends = () => {
Expand Down Expand Up @@ -108,12 +115,12 @@ export const Friends = () => {
<Avatar>{(""+name)[0]}</Avatar>
</Grid>
<Grid item xs={8}>
<Typography>{name}</Typography>
<Typography className="text-black dark:text-white">{". " + name}</Typography>
</Grid>
</Grid>
)
:
<Typography>{ t('Friends.noFriends') }</Typography>
<Typography className="text-black dark:text-white">{ t('Friends.noFriends') }</Typography>
}
</Stack>
</Box>
Expand All @@ -134,15 +141,15 @@ export const Friends = () => {
requests.map(request =>
<Grid container spacing={2} key={request.id}>
<Grid item xs={8}>
<Typography>{request.name}</Typography>
<Typography className="text-black dark:text-white">{request.name}</Typography>
</Grid>
<Grid item xs={4}>
<Button onClick={()=>acceptFriendRequest(request.from)}variant="outlined">{ t('Friends.accept') }</Button>
</Grid>
</Grid>
)
:
<Typography>{ t('Friends.noFriendRequest') }</Typography>
<Typography className="text-black dark:text-white">{ t('Friends.noFriendRequest') }</Typography>
}
</Stack>
</Box>
Expand Down
21 changes: 10 additions & 11 deletions webapp/src/components/game/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ import Swal from 'sweetalert2';
import i18n from "../../i18n";
import { useTranslation } from "react-i18next";


const token = localStorage.getItem("token");

let isFinished = async () => {
const number = await getNumberOfQuestions(token);
const settings = await getGameSettings(token);
const maxNumber = settings.numberOfQuestions;
return number > maxNumber;

}

export const Game = ({finishFunction, name, tags}) => {

const token = localStorage.getItem("token");

let isFinished = async () => {
const number = await getNumberOfQuestions(token);
const settings = await getGameSettings(token);
const maxNumber = settings.numberOfQuestions;
return number >= maxNumber;
}

const { t } = useTranslation();

const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/ranking/Ranking.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const Ranking = () =>
<div>
<span className='text-lg lg:text-3xl font-bold'>{ t('Ranking.user') }: { rank.user.name }</span>
<br />
<span className='text-lg lg:text-3xl'>{ t('Ranking.hit') }: { rank.hitsPercentage } %</span>
<span className='text-lg lg:text-3xl'>{ t('Ranking.hit') }: { rank.hitsPercentage.toFixed(2) } %</span>
</div>
)}

Expand Down
4 changes: 4 additions & 0 deletions webapp/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ i18n
},
Friends: {
friends: 'Friends',
success: 'Success!',
reqmsg: 'Friend request sent.',
noFriends: 'You have no friends.',
accept: 'Accept',
receivedFriendRequest: 'Friendship requests received',
Expand Down Expand Up @@ -179,6 +181,8 @@ i18n
},
Friends: {
friends: 'Amigos',
success: 'Exito',
reqmsg: 'Peticion de amistad enviada',
noFriends: 'No tienes amigos.',
accept: 'Aceptar',
receivedFriendRequest: 'Peticiones de amistad recibidas',
Expand Down

0 comments on commit 0efcdae

Please sign in to comment.