From 245dcf43b55bc02531f300109300ee39296130e2 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Sun, 4 Dec 2022 14:01:26 +0100 Subject: [PATCH] feat: login, basic admin dashboard --- frontend/src/lib/stores/candidate.ts | 8 +-- .../(authenticated)/dashboard/+page.svelte | 61 +++++++++++++++++++ .../(admin)/admin/auth/login/+page.svelte | 12 ++++ 3 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte diff --git a/frontend/src/lib/stores/candidate.ts b/frontend/src/lib/stores/candidate.ts index 31886d0..0d152af 100644 --- a/frontend/src/lib/stores/candidate.ts +++ b/frontend/src/lib/stores/candidate.ts @@ -19,10 +19,10 @@ export interface CandidateData { } export interface CandidatePreview { - applicationId: number; - name: string; - surname: string; - study: string; + applicationId?: number; + name?: string; + surname?: string; + study?: string; } export interface CandidateLogin { diff --git a/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte new file mode 100644 index 0000000..fb9e351 --- /dev/null +++ b/frontend/src/routes/(admin)/admin/(authenticated)/dashboard/+page.svelte @@ -0,0 +1,61 @@ + +
+
+
+ {#each candidates as candidate} +
+

{candidate.applicationId}

+
+

{candidate.name} {candidate.surname?.toUpperCase()}

+
+

Obor: {candidate.study}

+
+
+
+ {/each} +
+
+

Details here

+
+
+
+ + \ No newline at end of file diff --git a/frontend/src/routes/(admin)/admin/auth/login/+page.svelte b/frontend/src/routes/(admin)/admin/auth/login/+page.svelte index de1160e..b29a942 100644 --- a/frontend/src/routes/(admin)/admin/auth/login/+page.svelte +++ b/frontend/src/routes/(admin)/admin/auth/login/+page.svelte @@ -5,9 +5,20 @@ import background from '$lib/assets/background2.jpg'; import Lock from '$lib/components/icons/Lock.svelte'; + import { apiLogin } from '$lib/@api/admin'; + import { goto } from '$app/navigation'; let adminIdValue = ''; let adminPasswordValue = ''; + + const login = async () => { + try { + await apiLogin({adminId: Number(adminIdValue), password: adminPasswordValue}); + goto("/admin/dashboard"); + } catch (e) { + console.log(e); + } + }; @@ -37,6 +48,7 @@ class="bg-sspsBlue hover:bg-sspsBlueDark mt-8 w-3/5 rounded-lg p-3 text-xl font-semibold text-white transition-colors duration-300" type="submit" value="Odeslat" + on:click={login} />