|
|
@@ -3,13 +3,45 @@ import { Suspense } from "react";
|
|
|
import Search from "./Search";
|
|
|
import { SearchSkeleton } from "@/components/common/skeleton/SearchSkeleton";
|
|
|
import LogoIcon from "@components/common/icons/LogoIcon";
|
|
|
-import { CategoriesMenu } from "./CategoriesMenu";
|
|
|
+import MobileMenuTrigger from "./MobileMenuTrigger";
|
|
|
import { CartAndUserActions } from "./CartAndUserActions";
|
|
|
import { NavigationSkeleton } from "./NavigationSkeleton";
|
|
|
import { ActionsSkeleton } from "./ActionsSkeleton";
|
|
|
import { NavbarErrorBoundary } from "@/components/error/ErrorBoundary";
|
|
|
|
|
|
-export default function Navbar() {
|
|
|
+import { GET_TREE_CATEGORIES } from "@/graphql";
|
|
|
+import { cachedGraphQLRequest } from "@utils/hooks/useCache";
|
|
|
+import { TreeCategoriesResponse } from "@/types/theme/category-tree";
|
|
|
+
|
|
|
+export default async function Navbar() {
|
|
|
+
|
|
|
+ const data = await cachedGraphQLRequest<TreeCategoriesResponse>(
|
|
|
+ "category",
|
|
|
+ GET_TREE_CATEGORIES,
|
|
|
+ { parentId: 1 }
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ const categories = data?.treeCategories || [];
|
|
|
+
|
|
|
+ const filteredCategories = categories
|
|
|
+ .filter((cat: any) => cat.id !== "1")
|
|
|
+ .map((cat: any) => {
|
|
|
+ const translation = cat.translation;
|
|
|
+ return {
|
|
|
+ id: cat.id,
|
|
|
+ name: translation?.name || "",
|
|
|
+ slug: translation?.slug || "",
|
|
|
+ };
|
|
|
+ })
|
|
|
+ .filter((item: any) => item.name && item.slug);
|
|
|
+
|
|
|
+ const menuData = [
|
|
|
+ { id: "all", name: "All", slug: "" },
|
|
|
+ ...filteredCategories.slice(0, 3),
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
return (
|
|
|
<NavbarErrorBoundary>
|
|
|
<header className="sticky top-0 z-10">
|
|
|
@@ -17,18 +49,20 @@ export default function Navbar() {
|
|
|
<div className="flex w-full items-center justify-between gap-0 sm:gap-4">
|
|
|
{/* 1. THE STATIC SHELL (Visible Instantly) */}
|
|
|
<div className="flex max-w-fit gap-2 xl:gap-6">
|
|
|
+
|
|
|
+ {/* 2. STATIC HOLE: Categories (Suspended) */}
|
|
|
+ <Suspense fallback={<NavigationSkeleton />}>
|
|
|
+ <MobileMenuTrigger menuData={menuData} />
|
|
|
+ </Suspense>
|
|
|
<Link
|
|
|
- className="flex h-9 w-full scale-95 items-center md:h-9 md:w-auto lg:h-10"
|
|
|
+ className="flex-initial h-9 w-36.5"
|
|
|
href="/"
|
|
|
aria-label="Go to homepage"
|
|
|
>
|
|
|
<LogoIcon />
|
|
|
</Link>
|
|
|
|
|
|
- {/* 2. STATIC HOLE: Categories (Suspended) */}
|
|
|
- <Suspense fallback={<NavigationSkeleton />}>
|
|
|
- <CategoriesMenu />
|
|
|
- </Suspense>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<div className="hidden flex-1 justify-center md:flex">
|