From 1cde40b45916d1f99a4cda7837b516cde761f127 Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Sun, 2 Jan 2022 17:57:40 +0100
Subject: basic match views

---
 web/pw-server/src/routes/matches/index.svelte | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

(limited to 'web/pw-server/src/routes/matches/index.svelte')

diff --git a/web/pw-server/src/routes/matches/index.svelte b/web/pw-server/src/routes/matches/index.svelte
index dcfb43b..448048b 100644
--- a/web/pw-server/src/routes/matches/index.svelte
+++ b/web/pw-server/src/routes/matches/index.svelte
@@ -1 +1,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>
-- 
cgit v1.2.3

