feat: add ssr for dashboard

This commit is contained in:
EETagent 2022-12-03 16:48:06 +01:00
parent a95e89e8f1
commit 71f1e6b0b0
2 changed files with 14 additions and 11 deletions

View file

@ -8,4 +8,12 @@ export const load: LayoutServerLoad = async ({ fetch }) => {
if (details === null) { if (details === null) {
throw redirect(302, '/register'); throw redirect(302, '/register');
} }
return {
candidate: {
name: details.name,
surname: details.surname,
email: details.email
}
};
}; };

View file

@ -11,15 +11,10 @@
import PortfolioLetterUploadCard from '$lib/components/dashboard/PortfolioLetterUploadCard.svelte'; import PortfolioLetterUploadCard from '$lib/components/dashboard/PortfolioLetterUploadCard.svelte';
import PortfolioZipUploadCard from '$lib/components/dashboard/PortfolioZipUploadCard.svelte'; import PortfolioZipUploadCard from '$lib/components/dashboard/PortfolioZipUploadCard.svelte';
import { fetchSubmProgress } from '$lib/stores/portfolio'; import { fetchSubmProgress } from '$lib/stores/portfolio';
import type { PageData } from './$types';
let fullName = ""; export let data: PageData;
let email = "";
$: if ($candidateData) {
fullName = ($candidateData.name ?? "") + " " + ($candidateData.surname ?? "");
email = $candidateData.email ?? "";
}
fetchSubmProgress(); // TODO: move to a better place fetchSubmProgress(); // TODO: move to a better place
@ -39,8 +34,8 @@
<FullLayout> <FullLayout>
<div class="dashboard dashboardDesktop"> <div class="dashboard dashboardDesktop">
<div class="name col-span-3"> <div class="name col-span-3">
<DashboardInfoCard title={fullName}> <DashboardInfoCard title={data.candidate.name ?? ""}>
<span class="mt-3 text-sspsBlue truncate">{email}</span> <span class="mt-3 text-sspsBlue truncate">{data.candidate.email}</span>
<span class="mt-3 text-sspsGray text-xs">Uchazeč na SSPŠ</span> <span class="mt-3 text-sspsGray text-xs">Uchazeč na SSPŠ</span>
</DashboardInfoCard> </DashboardInfoCard>
</div> </div>
@ -56,8 +51,8 @@
</div> </div>
<div class="dashboard dashboardMobile"> <div class="dashboard dashboardMobile">
<div class="my-10 name w-[90%] mx-auto"> <div class="my-10 name w-[90%] mx-auto">
<DashboardInfoCard title={fullName}> <DashboardInfoCard title={data.candidate.name ?? ""}>
<span class="mt-3 text-sspsBlue truncate">{fullName}</span> <span class="mt-3 text-sspsBlue truncate">{data.candidate.email}</span>
<span class="mt-3 text-sspsGray text-xs">Uchazeč na SSPŠ</span> <span class="mt-3 text-sspsGray text-xs">Uchazeč na SSPŠ</span>
</DashboardInfoCard> </DashboardInfoCard>
</div> </div>