make error toast global in admin routes
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user