Add store for UUID and conditional loading of the LDB page for public/staff boards

This commit is contained in:
Fred Boniface
2023-06-19 13:22:17 +01:00
parent e4f18c389f
commit 847545760b
4 changed files with 137 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
<script>
import Header from '$lib/navigation/header.svelte'
import Nav from '$lib/navigation/nav.svelte'
import PublicLdb from '$lib/ldb/public-ldb.svelte';
import PublicLdb from '$lib/ldb/public-ldb.svelte';
import StaffLdb from '$lib/ldb/staff-ldb.svelte';
import { uuid } from '$lib/stores/uuid.js';
import {onMount} from 'svelte'
const title = "Public Board"
@@ -11,10 +13,17 @@
let station;
let staff;
let uuidValue;
$: uuidValue = $uuid;
onMount(async () => {
station = await getHeadcode() || "";
staff = false;
if (uuidValue !== null) {
staff = true;
} else {
staff = false;
}
})
</script>
@@ -24,6 +33,8 @@
<!-- If 'uuid' exists in store then load StaffLdb else load PublicLdb -->
{#if !staff}
<PublicLdb {station} />
{:else}
<StaffLdb {station} />
{/if}
<Nav />