|
|
|
|
@ -2,6 +2,7 @@ import { useEffect, useMemo } from "react";
|
|
|
|
|
import { Outlet, useLocation, useSearchParams } from "react-router-dom";
|
|
|
|
|
import usePrevious from "react-use/lib/usePrevious";
|
|
|
|
|
import Navigation from "@/components/Navigation";
|
|
|
|
|
import { useInstance } from "@/contexts/InstanceContext";
|
|
|
|
|
import { useMemoFilterContext } from "@/contexts/MemoFilterContext";
|
|
|
|
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
|
|
|
|
import useMediaQuery from "@/hooks/useMediaQuery";
|
|
|
|
|
@ -9,6 +10,25 @@ import useNavigateTo from "@/hooks/useNavigateTo";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import { ROUTES } from "@/router/routes";
|
|
|
|
|
import { redirectOnAuthFailure } from "@/utils/auth-redirect";
|
|
|
|
|
import { useTranslate } from "@/utils/i18n";
|
|
|
|
|
|
|
|
|
|
const MEMOS_DEPLOY_URL = "https://usememos.com/docs/deploy";
|
|
|
|
|
|
|
|
|
|
const DemoBanner = () => {
|
|
|
|
|
const t = useTranslate();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="static w-full border-b border-border bg-muted/70 px-4 py-2 text-sm text-muted-foreground sm:px-6">
|
|
|
|
|
<div className="mx-auto flex max-w-5xl flex-col items-start gap-1 sm:flex-row sm:items-center sm:justify-center sm:gap-2">
|
|
|
|
|
<span className="font-medium text-foreground">{t("demo.banner-title")}</span>
|
|
|
|
|
<span>{t("demo.banner-description")}</span>
|
|
|
|
|
<a className="font-medium text-primary underline-offset-4 hover:underline" href={MEMOS_DEPLOY_URL} target="_blank" rel="noreferrer">
|
|
|
|
|
{t("demo.deploy-link")}
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const RootLayout = () => {
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
@ -16,6 +36,7 @@ const RootLayout = () => {
|
|
|
|
|
const sm = useMediaQuery("sm");
|
|
|
|
|
const currentUser = useCurrentUser();
|
|
|
|
|
const navigateTo = useNavigateTo();
|
|
|
|
|
const { profile } = useInstance();
|
|
|
|
|
const { removeFilter } = useMemoFilterContext();
|
|
|
|
|
const pathname = useMemo(() => location.pathname, [location.pathname]);
|
|
|
|
|
const prevPathname = usePrevious(pathname);
|
|
|
|
|
@ -51,6 +72,7 @@ const RootLayout = () => {
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<main className="w-full h-auto grow shrink flex flex-col justify-start items-center">
|
|
|
|
|
{profile.demo && <DemoBanner />}
|
|
|
|
|
<Outlet />
|
|
|
|
|
</main>
|
|
|
|
|
</div>
|
|
|
|
|
|