aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/routes/matches/index.svelte
blob: 448048bcdc0636d01a4eee9dea3ce6aae045578f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<script lang="ts" context="module">
  export async function load() {
    const res = await fetch("/api/matches", {
      headers: {
        "Content-Type": "application/json",
      },
    });

    if (res.ok) {
      return {
        props: {
          matches: await res.json(),
        },
      };
    }

    return {
      status: res.status,
      error: new Error("failed to load matches"),
    };
  }
</script>

<script lang="ts">
  import dayjs from "dayjs";
  export let matches;
</script>

<a href="/matches/new">new match</a>
<ul>
  {#each matches as match}
    <li>
      <a href="/matches/{match['id']}">{dayjs(match["created_at"]).format("YYYY-MM-DD HH:mm")}</a>
    </li>
  {/each}
</ul>