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

<PageLayout title={t("dashboard.page")}>
    <script is:inline data-astro-rerun>
        import { l } from "../util/util";
        import { navigate } from "astro:transitions/client";
        import { loggedIn } from "../components/repo/authv2";
        loggedIn.subscribe((value) => {
            if (window.location.href.endsWith("/dashboard") || window.location.href.endsWith("/dashboard/")) {
                if (value === false) {
                    navigate(l("/dashboard"), { history: "replace" });
                }
            }
        });
    </script>
    <DashboardComponent client:only="svelte" />
</PageLayout>
