Skip to content

Commit

Permalink
Merge branch 'GameFrontEnd' of https://github.com/Arquisoft/wiq_en2a
Browse files Browse the repository at this point in the history
…into GameFrontEnd
  • Loading branch information
pelazas committed Mar 11, 2024
2 parents 47694f8 + 18e64f0 commit 3bf821b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion webapp/src/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ interface Question4Answers {
incorrectAnswer2: string;
incorrectAnswer3: string;
}

interface Score {
username: string;
points: string;
}
export type { Score }; // Export the 'Score' type
// Función para crear un juego


Expand Down
20 changes: 17 additions & 3 deletions webapp/src/components/Scoreboard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@



const Scoreboard = (

) => {
import { useState } from 'react';
import { Score } from './Game';

const [sorted, setSorted] = useState<Score[]>([]);

const Scoreboard = (userScores: Score[]) => {

//Get the scores and sort them
setSorted( userScores.sort((a, b) => {
return parseInt(b.points) - parseInt(a.points);
}));

//Return the scoreboard
return (
<div>
<h1>Scoreboard</h1>
<p>Here is the scoreboard</p>
<ul>
{sorted.map((score, index) => {
return <li key={index}>{score.username}: {score.points}</li>
})}
</ul>
</div>
)
}
Expand Down

0 comments on commit 3bf821b

Please sign in to comment.