This commit is contained in:
+9
-18
@@ -4,10 +4,6 @@ import { type FC, useEffect } from "react";
|
||||
// import AvatarImage from '../assets/images/avatar_image.png'
|
||||
import { Paths } from "@/config/Paths";
|
||||
import { clx } from "@/helpers/utils";
|
||||
import {
|
||||
isCatalogMongoId,
|
||||
useGetCatalogByIdOrSlug,
|
||||
} from "@/pages/home/hooks/useHomeData";
|
||||
import { useSharedStore } from "@/shared/store/sharedStore";
|
||||
import { Eye, HambergerMenu } from "iconsax-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -41,24 +37,19 @@ const Header: FC<HeaderProps> = ({
|
||||
// const location = useLocation();
|
||||
// const [popoverKey, setPopoverKey] = useState(0);
|
||||
const { t } = useTranslation("global");
|
||||
const { setOpenSidebar, openSidebar, hasSubMenu, setSearch } =
|
||||
useSharedStore();
|
||||
const {
|
||||
setOpenSidebar,
|
||||
openSidebar,
|
||||
hasSubMenu,
|
||||
setSearch,
|
||||
editorCatalogSlug,
|
||||
} = useSharedStore();
|
||||
const location = useLocation();
|
||||
const editorPathPrefix = `${Paths.editor}/`;
|
||||
const isEditorRoute =
|
||||
location.pathname.startsWith(editorPathPrefix) &&
|
||||
location.pathname.length > editorPathPrefix.length;
|
||||
const editorRouteParam = isEditorRoute
|
||||
? (location.pathname.slice(editorPathPrefix.length).split("/")[0] ?? "")
|
||||
: "";
|
||||
const { data: catalogData } = useGetCatalogByIdOrSlug(
|
||||
isEditorRoute && editorRouteParam ? editorRouteParam : "",
|
||||
);
|
||||
const viewerSlug =
|
||||
catalogData?.data?.slug ??
|
||||
(editorRouteParam && !isCatalogMongoId(editorRouteParam)
|
||||
? editorRouteParam
|
||||
: "");
|
||||
const viewerSlug = isEditorRoute ? (editorCatalogSlug ?? "") : "";
|
||||
|
||||
// useEffect(() => {
|
||||
// setPopoverKey((prevKey) => prevKey + 1);
|
||||
@@ -103,7 +94,7 @@ const Header: FC<HeaderProps> = ({
|
||||
{isEditorRoute && viewerSlug ? (
|
||||
<Link
|
||||
target="_blank"
|
||||
to={`${Paths.viewer}/${viewerSlug}`}
|
||||
to={`${Paths.viewerBySlug}/${viewerSlug}`}
|
||||
className="flex items-center"
|
||||
aria-label={t("header.open_viewer")}
|
||||
title={t("header.open_viewer")}
|
||||
|
||||
Reference in New Issue
Block a user