---
import Dashboard from "../components/Dashboard.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";

        document.addEventListener("astro:page-load", () => {
            if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) {
                if ((localStorage.getItem("sw-session") ?? "") === "") {
                    navigate(l("/login"), {});
                }
            }
        });
    </script>
    <Dashboard client:only="svelte" />
</PageLayout>