From b8d79e8cd9d6dcfe052831671ea6fa31fb846b9b Mon Sep 17 00:00:00 2001 From: EETagent Date: Sun, 1 Jan 2023 13:59:44 +0100 Subject: [PATCH] feat: move table to seperate component --- .../lib/components/admin/table/Table.svelte | 60 +++++++++++++++++++ .../src/lib/components/button/Delete.svelte | 14 +++-- .../(authenticated)/dashboard/+page.svelte | 54 +---------------- 3 files changed, 71 insertions(+), 57 deletions(-) create mode 100644 frontend/src/lib/components/admin/table/Table.svelte diff --git a/frontend/src/lib/components/admin/table/Table.svelte b/frontend/src/lib/components/admin/table/Table.svelte new file mode 100644 index 0000000..97755b7 --- /dev/null +++ b/frontend/src/lib/components/admin/table/Table.svelte @@ -0,0 +1,60 @@ + + +
+
+
+
+ + + + + + + + + + + {#each candidates as candidate} + + + + + + + + {/each} + +
Ev. č. přihlásky Jméno Příjmení Obor +
{candidate.applicationId} + {candidate.name} + + {candidate.surname} + + {candidate.study} + + +
+
+
+
+
+ + diff --git a/frontend/src/lib/components/button/Delete.svelte b/frontend/src/lib/components/button/Delete.svelte index 1e49128..ae1f330 100644 --- a/frontend/src/lib/components/button/Delete.svelte +++ b/frontend/src/lib/components/button/Delete.svelte @@ -5,14 +5,19 @@ export let value: string; - let isPrepared = false; + export let id: number | undefined; + let isPrepared = false; const buttonLogic = () => { if (isPrepared) { - dispatch('delete'); + dispatch('delete', { + id: id + }); } else { - dispatch('prepared'); + dispatch('prepared', { + id: id + }); isPrepared = true; setTimeout(() => { isPrepared = false; @@ -44,9 +49,8 @@ button { @apply inline-flex items-center; @apply bg-red-700; - @apply @apply rounded-lg p-3 text-xl font-semibold + @apply @apply rounded-lg p-3 font-semibold text-white transition-colors duration-300; - @apply w-full; animation: none !important; } diff --git a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte index f2e18b4..c50249c 100644 --- a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte +++ b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte @@ -7,6 +7,7 @@ import Fuse from 'fuse.js'; import type { PageServerData } from './$types'; import Delete from '$lib/components/button/Delete.svelte'; + import Table from '$lib/components/admin/table/Table.svelte'; export let data: PageServerData; @@ -112,58 +113,7 @@ {/if} -
-
-
-
- - - - - - - - - - - {#each candidatesTable as candidate} - - - - - - - - {/each} - -
- Ev. č. přihlásky - Jméno - Příjmení - Obor -
{candidate.applicationId} - {candidate.name} - - {candidate.surname} - - {candidate.study} - - await deleteCandidate(candidate.applicationId)} - value="Odstranit" - /> -
-
-
-
-
+ deleteCandidate(event.detail.id)} />