Skip to content

Commit

Permalink
Create AssetList component which isolates dynamic content
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanqui committed Jan 8, 2025
1 parent 7cc2590 commit b69ca1a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
20 changes: 20 additions & 0 deletions src/lib/AssetList.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script lang="ts">
import { type AssetData } from "$src/types";
import AssetBox from "$src/lib/AssetBox.svelte";
import { loadRHInventoryAssetData } from '$src/lib/rhinventory_api';
let props: { assetTagId: number } = $props();
let assetPage = $state(0);
let assetsPromise: Promise<AssetData[]> = $derived(loadRHInventoryAssetData({tagId: props.assetTagId, page: assetPage}))
</script>

{#await assetsPromise }
<p><em>Načítá se...</em></p>
{:then assets}
{#each assets as asset }
<AssetBox data={asset} />
{/each}
{:catch error}
<p><em>Chyba při načítání předmětů: {error.message}</em></p>
{/await}
20 changes: 3 additions & 17 deletions src/routes/projects/atari-klub-citov/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<script lang="ts">
import Meta from "$lib/Meta.svelte";
import type { AssetData, InterviewData } from "$src/types";
import type { InterviewData } from "$src/types";
import InterviewBox from "$lib/InterviewBox.svelte";
import { data as havelka_data } from '$src/routes/interviews/josef-havelka/interview';
import AssetBox from "$src/lib/AssetBox.svelte";
import { loadRHInventoryAssetData } from '$src/lib/rhinventory_api';
import AssetList from "$src/lib/AssetList.svelte";
let interviews: InterviewData[] = [havelka_data];
let assetPage = $state(0);
const assetTagId = 16;
let assetsPromise: Promise<AssetData[]> = $derived(loadRHInventoryAssetData({tagId: assetTagId, page: assetPage}))
</script>

<Meta title="Atari klub Cítov" />
Expand Down Expand Up @@ -45,16 +40,7 @@
{/each}

<h3 id="Predmety">Předměty</h3>

{#await assetsPromise }
<p><em>Načítá se...</em></p>
{:then assets}
{#each assets as asset }
<AssetBox data={asset} />
{/each}
{:catch error}
<p><em>Chyba při načítání předmětů: {error.message}</em></p>
{/await}
<AssetList assetTagId={16} />

<!-- <h3>Články</h3>
<p><em>Sem přijdou případné články.</em> -->
Expand Down

0 comments on commit b69ca1a

Please sign in to comment.