adapt frontend to new match api
This commit is contained in:
parent
4dc77e1626
commit
8f29332048
1 changed files with 25 additions and 3 deletions
|
@ -51,13 +51,35 @@
|
|||
|
||||
async function selectMatch(matchId: string) {
|
||||
console.log("showing match " + matchId);
|
||||
let matchLog = await loadMatch(matchId);
|
||||
let matchLog = await getMatchLog(matchId);
|
||||
selectedMatchId = matchId;
|
||||
selectedMatchLog = matchLog;
|
||||
}
|
||||
|
||||
async function loadMatch(matchId: string) {
|
||||
const res = await fetch(`/api/matches/${matchId}`, {
|
||||
async function getMatchData(matchId: string) {
|
||||
let response = await fetch(`/api/matches/${matchId}`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw Error(response.statusText);
|
||||
}
|
||||
|
||||
let matchData = await response.json();
|
||||
return matchData;
|
||||
}
|
||||
|
||||
async function getMatchLog(matchId: string) {
|
||||
const matchData = await getMatchData(matchId);
|
||||
console.log(matchData);
|
||||
if (matchData["state"] !== "Finished") {
|
||||
// log is not available yet
|
||||
return null;
|
||||
}
|
||||
|
||||
const res = await fetch(`/api/matches/${matchId}/log`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue