import { useEffect } from "react";
import { NavLink, useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { useLayoutStore, useUserStore } from "../store/module";
import { resolution } from "../utils/layout";
import Icon from "./Icon";
import showSettingDialog from "./SettingDialog";
import showAskAIDialog from "./AskAIDialog";
import showArchivedMemoDialog from "./ArchivedMemoDialog";
import showAboutSiteDialog from "./AboutSiteDialog";
import UserBanner from "./UserBanner";
const Header = () => {
const { t } = useTranslation();
const location = useLocation();
const userStore = useUserStore();
const layoutStore = useLayoutStore();
const showHeader = layoutStore.state.showHeader;
const isVisitorMode = userStore.isVisitorMode() && !userStore.state.user;
useEffect(() => {
const handleWindowResize = () => {
if (window.innerWidth < resolution.sm) {
layoutStore.setHeaderStatus(false);
} else {
layoutStore.setHeaderStatus(true);
}
};
window.addEventListener("resize", handleWindowResize);
handleWindowResize();
}, [location]);
return (
layoutStore.setHeaderStatus(false)}
>
{!isVisitorMode && (
<>
`${
isActive && "bg-white dark:bg-zinc-700 shadow"
} px-4 pr-5 py-2 rounded-lg flex flex-row items-center text-lg dark:text-gray-200 hover:bg-white hover:shadow dark:hover:bg-zinc-700`
}
>
<>
{t("common.home")}
>
`${
isActive && "bg-white dark:bg-zinc-700 shadow"
} px-4 pr-5 py-2 rounded-lg flex flex-row items-center text-lg dark:text-gray-200 hover:bg-white hover:shadow dark:hover:bg-zinc-700`
}
>
<>
{t("common.daily-review")}
>
`${
isActive && "bg-white dark:bg-zinc-700 shadow"
} px-4 pr-5 py-2 rounded-lg flex flex-row items-center text-lg dark:text-gray-200 hover:bg-white hover:shadow dark:hover:bg-zinc-700`
}
>
<>
{t("common.resources")}
>
>
)}
`${
isActive && "bg-white dark:bg-zinc-700 shadow"
} px-4 pr-5 py-2 rounded-lg flex flex-row items-center text-lg dark:text-gray-200 hover:bg-white hover:shadow dark:hover:bg-zinc-700`
}
>
<>
{t("common.explore")}
>
{!isVisitorMode && (
<>
>
)}
{isVisitorMode && (
<>
`${
isActive && "bg-white dark:bg-zinc-700 shadow"
} px-4 pr-5 py-2 rounded-lg flex flex-row items-center text-lg dark:text-gray-200 hover:bg-white hover:shadow dark:hover:bg-zinc-700`
}
>
<>
{t("common.sign-in")}
>
>
)}
);
};
export default Header;