hackathon/web_src/routes/dashboard/__layout-dashboard.svelte

23 lines
414 B
Svelte

<script lang="ts">
import { getContext, onMount } from 'svelte';
import { auth } from '$lib/stores';
import LoginModal from '$lib/components/LoginModal.svelte';
const { open } = getContext('simple-modal');
const goHome = () => {
open(LoginModal);
window.location.href = '/';
};
onMount(() => {
auth.subscribe((auth) => {
if (!auth.loggedIn()) {
goHome();
}
});
});
</script>
<slot />