File size: 953 Bytes
7b25d55
 
 
 
 
 
35140b4
 
 
 
 
 
 
 
 
 
 
 
7b25d55
 
 
 
 
 
 
 
 
 
 
 
 
35140b4
7b25d55
 
 
 
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">
	import Card from "$lib/components/community/Card.svelte";
	import GoTop from "$lib/components/GoTop.svelte";

  export let data

	const handleDelete = async (id: string) => {
		const request = await fetch(`/api/community/${id}`, {
			method: "DELETE"
		});
		const { success } = await request.json();
		if (success) {
			data = {
				...data,
				cards: data.cards.filter((card: any) => card.id !== id)
			}
		}
	}
</script>

<svelte:head>
	<title>My saved generations</title>
	<meta name="description" content="Svelte demo app" />
</svelte:head>

<main class="px-6 py-10 lg:px-10 lg:py-12">
	<h1 class="text-white font-semibold text-2xl">
		Saved generations ({data.total_items})
	</h1>
	<div class="mx-auto grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 2xl:grid-cols-4 gap-5 mt-8 lg:mt-10">
		{#each data.cards as card}
			<Card card={card} displayReactions={false} onDelete={handleDelete} />
		{/each}
		<GoTop />
	</div>
</main>