This commit is contained in:
Nikolaj
2026-03-16 14:01:22 +01:00
parent 5d54d1cf7b
commit 65b719334f
19 changed files with 848 additions and 96 deletions

View File

@@ -1,21 +1,29 @@
<script>
import Card from "$lib/Card.svelte";
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
import Card from '$lib/Card.svelte';
let cards = $state([]);
let loading = $state(false);
onMount(() => {
if (!localStorage.getItem('token')) goto('/auth');
});
async function openPack() {
loading = true;
try {
const res = await fetch("http://localhost:8000/pack/14");
if (!res.ok) throw new Error(`HTTP ${res.status}`);
cards = await res.json();
} catch (e) {
console.error("Failed to open pack:", e);
} finally {
loading = false;
loading = true;
try {
const res = await fetch('http://localhost:8000/pack/10', {
headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }
});
if (res.status === 401) { goto('/auth'); return; }
cards = await res.json();
} catch (e) {
console.error(e);
} finally {
loading = false;
}
}
}
</script>
<main>
@@ -33,7 +41,7 @@
<style>
main {
min-height: 100vh;
background: #0d0a04;
background: #887859;
padding: 2rem;
}