1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-01 19:25:17 +02:00
AdventureLog/frontend/src/routes/search/+page.svelte

29 lines
811 B
Svelte
Raw Normal View History

2024-07-17 17:36:05 -04:00
<script lang="ts">
import AdventureCard from '$lib/components/AdventureCard.svelte';
import NotFound from '$lib/components/NotFound.svelte';
import type { Adventure } from '$lib/types';
import type { PageData } from './$types';
export let data: PageData;
2024-07-17 22:06:55 -04:00
function deleteAdventure(event: CustomEvent<number>) {
adventures = adventures.filter((adventure) => adventure.id !== event.detail);
}
2024-07-17 17:36:05 -04:00
console.log(data);
let adventures: Adventure[] = [];
if (data.props) {
adventures = data.props.adventures;
}
</script>
{#if adventures.length === 0}
2024-07-18 14:55:23 -04:00
<NotFound error={data.error} />
2024-07-17 17:36:05 -04:00
{:else}
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each adventures as adventure}
2024-07-17 22:06:55 -04:00
<AdventureCard type={adventure.type} {adventure} on:delete={deleteAdventure} />
{/each}
</div>
2024-07-17 17:36:05 -04:00
{/if}