---
import DashboardComponent from "@components/DashboardComponent.svelte";
import PageLayout from "@layouts/PageLayout.astro";
import {t} from "astro-i18n";
---

<PageLayout title={t("dashboard.page")}>
    <script>
        import {l} from "../util/util";
        import {navigate} from "astro:transitions/client";
        import {get} from "svelte/store";
        import {loggedIn} from "../components/repo/authv2";
        document.addEventListener("astro:page-load", () => {
            if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) {
                if (!get(loggedIn)) {
                    navigate(l("/login"), {});
                }
            }
        });
    </script>
    <DashboardComponent client:only="svelte" />
</PageLayout>