Browse Source

suposed working history window

master
nicolas-arnaud 2 years ago
parent
commit
39b4958f8a
  1. 1
      back/volume/package.json
  2. 17
      front/volume/src/App.svelte
  3. 13
      front/volume/src/components/MatchHistory.svelte

1
back/volume/package.json

@ -63,7 +63,6 @@
"ws": "^8.11.0"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@types/jest": "28.1.8",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.53.0",

17
front/volume/src/App.svelte

@ -52,14 +52,15 @@
function clickHistory() {
isHistoryOpen = true;
}
let matches: Array<Match> = [
{ winner: "Alice", loser: "Bob", points: -5, rank: "22" },
{ winner: "Alice", loser: "Bob", points: 10, rank: "24" },
{ winner: "Alice", loser: "Bob", points: 10, rank: "24" },
{ winner: "Alice", loser: "Bob", points: 7, rank: "23" },
{ winner: "Alice", loser: "Bob", points: 10, rank: "24" },
{ winner: "Alice", loser: "Bob", points: 10, rank: "24" },
];
let matches: Array<Match>;
export async function getHistory(): Promise<Match[]> {
let response = await fetch(API_URL + "/history/" + $store.ftId, {
credentials: "include",
mode: "cors",
});
return await response.json();
}
// FRIENDS

13
front/volume/src/components/MatchHistory.svelte

@ -1,10 +1,11 @@
<script lang="ts" context="module">
import type user from './Profile.svelte'
export interface Match {
winner: string;
loser: string;
points: number;
rank: string;
players: Array<user>;
scores: Array<number>;
date: Date;
}
</script>
<script lang="ts">
@ -18,13 +19,15 @@
<h2>Last 10 monkey games</h2>
{#each matches.slice(0, 10) as match}
<li>
<span>{match.winner} 1 - 0 {match.loser}</span>
<span>{match.date.toString()}: {match.players[0].username} {match.scores[0]} - {match.scores[1]} {match.players[1].username}</span>
<!---
{#if match.points > 0}
<span>+{match.points}</span>
{:else}
<span>{match.points}</span>
{/if}
<span>MP | rank #{match.rank}</span>
--->
</li>
{/each}
{:else}

Loading…
Cancel
Save