diff --git a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+layout.server.ts b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+layout.server.ts new file mode 100644 index 0000000..27927e4 --- /dev/null +++ b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+layout.server.ts @@ -0,0 +1,16 @@ +import { apiListCandidates } from '$lib/@api/admin'; +import type { CandidatePreview } from '$lib/stores/candidate'; +import type { LayoutServerLoad } from './$types'; + +export const load: LayoutServerLoad = async ({ fetch }) => { + let candidatePreview: [CandidatePreview] = [{}]; + try { + candidatePreview = await apiListCandidates(fetch); + } catch (e) { + console.error(e); + } + + return { + preview: candidatePreview, + }; +}; diff --git a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte index 3ddb157..4f42a84 100644 --- a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte +++ b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte @@ -7,11 +7,16 @@ import type { CandidateData, CandidatePreview } from '$lib/stores/candidate'; import ListElement from '$lib/components/dashboard/ListElement.svelte'; import CandidateDetails from '$lib/components/dashboard/CandidateDetails.svelte'; + import { onMount } from 'svelte'; let candidates: [CandidatePreview] = [{}]; let candidateDetails: { [id: number]: CandidateData } = {}; - getCandidates(); + export let data: PageData; + + onMount(() => { + candidates = data.preview; + }); async function getCandidates() { try { @@ -60,7 +65,10 @@ {#if scrollTop > 200}
- +
{/if} @@ -71,15 +79,22 @@ - + - + {#each candidates as candidate} - toggleDetail(candidate.applicationId)} class="hover:cursor-pointer border-b bg-white"> + toggleDetail(candidate.applicationId)} + class="border-b bg-white hover:cursor-pointer" + > @@ -95,11 +110,11 @@ {#if candidateDetails.hasOwnProperty(candidate.applicationId)}
- - -
+ candidate={candidateDetails[candidate.applicationId]} + /> +
{/if} {/each}
Ev. č. přihlásky + Ev. č. přihlásky + Jméno Příjmení + Příjmení + Obor
{candidate.applicationId}