make error toast global in admin routes

This commit is contained in:
2023-10-04 14:28:35 +02:00
parent 8a80b0a9e0
commit 85597585da
5 changed files with 28 additions and 15 deletions

View File

@@ -5,7 +5,8 @@
import { buttonTriggeredRequest } from '$lib/components/utils';
import { goto } from '$app/navigation';
import type { LayoutData } from './$types';
import { adminCount, reportCount } from '$lib/stores';
import { adminCount, errorMessage, reportCount } from '$lib/stores';
import ErrorToast from '$lib/components/Toast/ErrorToast.svelte';
async function logout() {
const response = await fetch(`${env.PUBLIC_BASE_PATH}/admin/logout`, {
@@ -21,6 +22,8 @@
export let data: LayoutData;
if (data.reportCount) $reportCount = data.reportCount;
if (data.adminCount) $adminCount = data.adminCount;
errorMessage.subscribe(console.log);
</script>
{#if $page.url.pathname !== `${env.PUBLIC_BASE_PATH}/admin/login`}
@@ -71,3 +74,9 @@
<slot />
</div>
{/if}
{#if $errorMessage}
<ErrorToast timeout={2000} show={$errorMessage != null}>
<span>{$errorMessage}</span>
</ErrorToast>
{/if}