|
@@ -1,20 +1,14 @@
|
|
|
import Link from "next/link";
|
|
import Link from "next/link";
|
|
|
import { Suspense } from "react";
|
|
import { Suspense } from "react";
|
|
|
-// import Search from "./Search";
|
|
|
|
|
-// import { SearchSkeleton } from "@/components/common/skeleton/SearchSkeleton";
|
|
|
|
|
import LogoIcon from "@components/common/icons/LogoIcon";
|
|
import LogoIcon from "@components/common/icons/LogoIcon";
|
|
|
import MobileMenuTrigger from "./MobileMenuTrigger";
|
|
import MobileMenuTrigger from "./MobileMenuTrigger";
|
|
|
-import { CartAndUserActions } from "./CartAndUserActions";
|
|
|
|
|
|
|
+import { NavbarActions } from "./NavbarActions";
|
|
|
import { NavigationSkeleton } from "./NavigationSkeleton";
|
|
import { NavigationSkeleton } from "./NavigationSkeleton";
|
|
|
-import { ActionsSkeleton } from "./ActionsSkeleton";
|
|
|
|
|
import { NavbarErrorBoundary } from "@/components/error/ErrorBoundary";
|
|
import { NavbarErrorBoundary } from "@/components/error/ErrorBoundary";
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
- // GET_TREE_CATEGORIES,
|
|
|
|
|
GET_TREEFRONT_MENUS } from "@/graphql";
|
|
GET_TREEFRONT_MENUS } from "@/graphql";
|
|
|
-// import { cachedGraphQLRequest } from "@utils/hooks/useCache";
|
|
|
|
|
import { serverGraphqlFetch } from "@utils/bagisto/index";
|
|
import { serverGraphqlFetch } from "@utils/bagisto/index";
|
|
|
-// import { TreeCategoriesResponse } from "@/types/theme/category-tree";
|
|
|
|
|
import NavbarSearchIcon from "./NavbarSearchIcon"
|
|
import NavbarSearchIcon from "./NavbarSearchIcon"
|
|
|
import type { GetTreefrontMenusResult } from "@/types/theme/menus";
|
|
import type { GetTreefrontMenusResult } from "@/types/theme/menus";
|
|
|
import { authOptions } from "@utils/auth";
|
|
import { authOptions } from "@utils/auth";
|
|
@@ -23,37 +17,14 @@ export default async function Navbar() {
|
|
|
|
|
|
|
|
const session = await getServerSession(authOptions);// 游客是null
|
|
const session = await getServerSession(authOptions);// 游客是null
|
|
|
const isGuest = session === null;
|
|
const isGuest = session === null;
|
|
|
- // const { data } = await cachedGraphQLRequest<TreeCategoriesResponse>(
|
|
|
|
|
- // "category",
|
|
|
|
|
- // GET_TREE_CATEGORIES,
|
|
|
|
|
- // { parentId: 1 },
|
|
|
|
|
- // );
|
|
|
|
|
- // console.log('TreeCategoriesResponse --- ',data)
|
|
|
|
|
- // const categories = data?.treeCategories || [];
|
|
|
|
|
- const { data: menudata } = await serverGraphqlFetch<
|
|
|
|
|
- GetTreefrontMenusResult
|
|
|
|
|
->({
|
|
|
|
|
- query: GET_TREEFRONT_MENUS,
|
|
|
|
|
-});
|
|
|
|
|
-console.log('GetTreefrontMenusResult --- ',menudata)
|
|
|
|
|
- const menudatas =menudata? menudata.treefrontMenus:[];
|
|
|
|
|
- // const filteredCategories = categories
|
|
|
|
|
- // .filter((cat: any) => cat.id !== "1")
|
|
|
|
|
- // .map((cat: any) => {
|
|
|
|
|
- // const translation = cat.translation;
|
|
|
|
|
- // return {
|
|
|
|
|
- // id: cat.id,
|
|
|
|
|
- // _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),
|
|
|
|
|
- // ];
|
|
|
|
|
|
|
+ const { data: menudata } = await serverGraphqlFetch<
|
|
|
|
|
+ GetTreefrontMenusResult
|
|
|
|
|
+ >({
|
|
|
|
|
+ query: GET_TREEFRONT_MENUS,
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log('GetTreefrontMenusResult --- ',menudata)
|
|
|
|
|
+ const menudatas =menudata? menudata.treefrontMenus:[];
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<NavbarErrorBoundary>
|
|
<NavbarErrorBoundary>
|
|
@@ -81,10 +52,9 @@ console.log('GetTreefrontMenusResult --- ',menudata)
|
|
|
<LogoIcon />
|
|
<LogoIcon />
|
|
|
</Link>
|
|
</Link>
|
|
|
|
|
|
|
|
- {/* 3. DYNAMIC HOLE: Auth & Cart (Blocked by Session/Cookies) */}
|
|
|
|
|
- <Suspense fallback={<ActionsSkeleton />}>
|
|
|
|
|
- <CartAndUserActions />
|
|
|
|
|
- </Suspense>
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <NavbarActions isGuest={isGuest} />
|
|
|
|
|
+
|
|
|
</div>
|
|
</div>
|
|
|
</nav>
|
|
</nav>
|
|
|
</header>
|
|
</header>
|