mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-09 01:30:18 +00:00
feat: ssr for candidate table
This commit is contained in:
parent
c482287c3e
commit
c275912786
2 changed files with 40 additions and 9 deletions
|
|
@ -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,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -7,11 +7,16 @@
|
||||||
import type { CandidateData, CandidatePreview } from '$lib/stores/candidate';
|
import type { CandidateData, CandidatePreview } from '$lib/stores/candidate';
|
||||||
import ListElement from '$lib/components/dashboard/ListElement.svelte';
|
import ListElement from '$lib/components/dashboard/ListElement.svelte';
|
||||||
import CandidateDetails from '$lib/components/dashboard/CandidateDetails.svelte';
|
import CandidateDetails from '$lib/components/dashboard/CandidateDetails.svelte';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
let candidates: [CandidatePreview] = [{}];
|
let candidates: [CandidatePreview] = [{}];
|
||||||
let candidateDetails: { [id: number]: CandidateData } = {};
|
let candidateDetails: { [id: number]: CandidateData } = {};
|
||||||
|
|
||||||
getCandidates();
|
export let data: PageData;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
candidates = data.preview;
|
||||||
|
});
|
||||||
|
|
||||||
async function getCandidates() {
|
async function getCandidates() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -60,7 +65,10 @@
|
||||||
</div>
|
</div>
|
||||||
{#if scrollTop > 200}
|
{#if scrollTop > 200}
|
||||||
<div class="fixed bottom-8 right-8">
|
<div class="fixed bottom-8 right-8">
|
||||||
<button class="w-16 h-16 text-white text-lg font-semibold rounded-full p-6 bg-sspsBlue flex items-center justify-center">+</button>
|
<button
|
||||||
|
class="bg-sspsBlue flex h-16 w-16 items-center justify-center rounded-full p-6 text-lg font-semibold text-white"
|
||||||
|
>+</button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
@ -71,15 +79,22 @@
|
||||||
<table class="min-w-full rounded-md border-2 border-[#dfe0e9] text-center">
|
<table class="min-w-full rounded-md border-2 border-[#dfe0e9] text-center">
|
||||||
<thead class="bg-[#f6f4f4] ">
|
<thead class="bg-[#f6f4f4] ">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Ev. č. přihlásky </th>
|
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900">
|
||||||
|
Ev. č. přihlásky
|
||||||
|
</th>
|
||||||
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Jméno </th>
|
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Jméno </th>
|
||||||
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Příjmení </th>
|
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900">
|
||||||
|
Příjmení
|
||||||
|
</th>
|
||||||
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Obor </th>
|
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Obor </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each candidates as candidate}
|
{#each candidates as candidate}
|
||||||
<tr on:click={e=> toggleDetail(candidate.applicationId)} class="hover:cursor-pointer border-b bg-white">
|
<tr
|
||||||
|
on:click={(e) => toggleDetail(candidate.applicationId)}
|
||||||
|
class="border-b bg-white hover:cursor-pointer"
|
||||||
|
>
|
||||||
<td class="whitespace-nowrap px-6 py-4 text-sm text-gray-900"
|
<td class="whitespace-nowrap px-6 py-4 text-sm text-gray-900"
|
||||||
>{candidate.applicationId}</td
|
>{candidate.applicationId}</td
|
||||||
>
|
>
|
||||||
|
|
@ -95,11 +110,11 @@
|
||||||
</tr>
|
</tr>
|
||||||
{#if candidateDetails.hasOwnProperty(candidate.applicationId)}
|
{#if candidateDetails.hasOwnProperty(candidate.applicationId)}
|
||||||
<div class="mb-20 w-full">
|
<div class="mb-20 w-full">
|
||||||
<CandidateDetails
|
<CandidateDetails
|
||||||
id={candidate.applicationId}
|
id={candidate.applicationId}
|
||||||
candidate={candidateDetails[candidate.applicationId]}>
|
candidate={candidateDetails[candidate.applicationId]}
|
||||||
</CandidateDetails>
|
/>
|
||||||
<hr class="border-4 w-full">
|
<hr class="w-full border-4" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue