From fb1b5e0bbd373abbcf85e3c3f37aa4ac3ac7b948 Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Sat, 11 Mar 2023 19:39:31 +0100 Subject: [PATCH] view personals history in profiles --- front/volume/src/App.svelte | 32 ++++++++++++++++++---- front/volume/src/components/Profile.svelte | 7 +++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/front/volume/src/App.svelte b/front/volume/src/App.svelte index 552c6fd..14670ec 100644 --- a/front/volume/src/App.svelte +++ b/front/volume/src/App.svelte @@ -3,6 +3,7 @@ HOME = "/", PROFILE = "/profile", HISTORY = "/history", + HISTORY_ID = "/history_id", FRIENDS = "/friends", SPECTATE = "/spectate", CHANNELS = "/channels", @@ -61,6 +62,7 @@ setInterval(() => { getUser(); }, 15000); + function clickProfile() { setAppState(APPSTATE.PROFILE); } @@ -80,12 +82,13 @@ } // HISTORY - let matches: Array; async function clickHistory() { setAppState(APPSTATE.HISTORY); matches = await getHistory(); } + let matches: Array; + export async function getHistory(): Promise> { let response = await fetch(API_URL + "/rankedHistory/", { credentials: "include", @@ -94,19 +97,29 @@ return await response.json(); } + async function openIdHistory(event: CustomEvent) { + console.log("Opening history: " + event.detail); + const res = await fetch(API_URL + "/history/" + event.detail, { + credentials: "include", + mode: "cors", + }); + matches = await res.json(); + setAppState(APPSTATE.HISTORY_ID); + } + // FRIENDS let friends: Friend[] = []; let invits: Friend[] = []; let friendsInterval: ReturnType; - export async function getFriends(): Promise { + async function getFriends(): Promise { let response = await fetch(API_URL + "/friends", { credentials: "include", mode: "cors", }); return await response.json(); } - export async function getInvits(): Promise { + async function getInvits(): Promise { let response = await fetch(API_URL + "/invits", { credentials: "include", mode: "cors", @@ -235,14 +248,23 @@ {/if} + {#if appState === APPSTATE.HISTORY_ID} +
+ +
+ {/if} {#if appState === APPSTATE.PROFILE}
- +
{/if} {#if appState === APPSTATE.PROFILE_ID}
- +
{/if} diff --git a/front/volume/src/components/Profile.svelte b/front/volume/src/components/Profile.svelte index fdc83f3..9c46926 100644 --- a/front/volume/src/components/Profile.svelte +++ b/front/volume/src/components/Profile.svelte @@ -11,11 +11,13 @@