temporary setup for showing submission match result

This commit is contained in:
Ilion Beyst 2022-02-02 19:36:18 +01:00
parent 2e3606f1b6
commit db45cea37e
2 changed files with 38 additions and 4 deletions

View file

@ -1,4 +1,6 @@
<script lang="ts">
import { goto } from "$app/navigation";
let code = "";
async function submitCode() {
@ -9,7 +11,7 @@
"Content-Type": "application/json",
},
body: JSON.stringify({
"code": code,
code: code,
}),
});
@ -17,8 +19,9 @@
throw Error(response.statusText);
}
let responseData = await response.json()
console.log(responseData);
let responseData = await response.json();
let matchId = responseData["match_id"];
goto(`/submission_matches/${matchId}`);
}
</script>

View file

@ -0,0 +1,31 @@
<script lang="ts" context="module">
export async function load({ page }) {
const res = await fetch(`/api/submission_match_log/${page.params["match_id"]}`, {
headers: {
"Content-Type": "application/json",
},
});
if (res.ok) {
return {
props: {
matchLog: await res.text(),
},
};
}
return {
status: res.status,
error: new Error("failed to load match"),
};
}
</script>
<script lang="ts">
import Visualizer from "$lib/components/Visualizer.svelte";
export let matchLog: string;
</script>
<div>
<Visualizer {matchLog} />
</div>