Files
packager/ui/src/routes/PackageLists.svelte

39 lines
1.1 KiB
Svelte
Raw Normal View History

2021-09-06 18:08:52 +02:00
<script lang="ts">
import PackageList from "../components/PackageList.svelte"
2021-09-07 00:02:53 +02:00
export let redirect;
export let data;
export const url = "/lists/"
async function getLists() {
2021-09-06 18:08:52 +02:00
let response = await fetch("http://localhost:9000/v1/lists", {
method: "GET",
headers: {
"Accept": "application/json"
},
cache: "no-store",
});
2021-09-07 00:02:53 +02:00
let lists = await response.json();
return lists;
2021-09-06 18:08:52 +02:00
}
</script>
<main>
<div>
2021-09-07 00:02:53 +02:00
{#await getLists()}
2021-09-06 18:08:52 +02:00
<p>Loading</p>
{:then lists}
<div class="m-2 grid grid-cols-3 gap-5 items-start grid-flow-row">
{#each lists as list}
<div class="p-3 border rounded-lg border-gray-300 shadow hover:shadow-xl bg-gray-100 bg-opacity-30 hover:bg-opacity-100">
2021-09-07 00:02:53 +02:00
<PackageList id={list.id} name={list.name} items={list.items} on:select={e => redirect(url + e.detail.id)} />
2021-09-06 18:08:52 +02:00
</div>
{/each}
</div>
{:catch error}
<p>Something went wrong</p>
{/await}
</div>
</main>