This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import { MainLayout } from "@/components/templates/main-layout";
|
||||
import { ManagerProvider } from "@/lib/manager-context";
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return <MainLayout>{children}</MainLayout>;
|
||||
return (
|
||||
<MainLayout>
|
||||
<ManagerProvider>{children}</ManagerProvider>
|
||||
</MainLayout>
|
||||
);
|
||||
}
|
||||
|
||||
+7
-16
@@ -4,14 +4,19 @@ import { SearchBar } from "@/components/molecules/search-bar";
|
||||
import { CategorySidebar } from "@/components/organisms/navigation";
|
||||
import { ProductGrid } from "@/components/organisms/product-grid";
|
||||
import { eateryClient } from "@/lib/apollo-clients";
|
||||
import { useMenu } from "@/lib/menu-context";
|
||||
import { allEateriesQuery } from "@/lib/types";
|
||||
import { gql } from "@apollo/client";
|
||||
import { useQuery } from "@apollo/client/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const GET_EATERY_COUNT = gql`{ allEateries { id } }`;
|
||||
const GET_EATERY_COUNT = gql`
|
||||
{
|
||||
allEateries {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* Main page — sidebar + product grid layout.
|
||||
@@ -24,7 +29,6 @@ const GET_EATERY_COUNT = gql`{ allEateries { id } }`;
|
||||
* - Mobile (< 1024px): collapsed by default
|
||||
*/
|
||||
export default function Home() {
|
||||
const { activeCategory, setActiveCategory } = useMenu();
|
||||
const router = useRouter();
|
||||
|
||||
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
||||
@@ -58,23 +62,11 @@ export default function Home() {
|
||||
return () => mq.removeEventListener("change", handler);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setSearchQuery("");
|
||||
}, [activeCategory]);
|
||||
|
||||
if (loading) return <div>Loading...</div>;
|
||||
if (error) return <div>Error: {error.message}</div>;
|
||||
|
||||
return (
|
||||
<div className="bg-background flex min-h-[calc(100vh-var(--spacing-header-height))] items-start">
|
||||
{/* ── Sidebar ── */}
|
||||
<CategorySidebar
|
||||
isOpen={isSidebarOpen}
|
||||
onToggle={() => setIsSidebarOpen((prev) => !prev)}
|
||||
activeCategory={activeCategory}
|
||||
onCategoryChange={setActiveCategory}
|
||||
/>
|
||||
|
||||
{/* ── Main content ── */}
|
||||
<main className="min-w-0 flex-1 px-4 py-6 md:px-6 lg:px-8">
|
||||
{/* ── Section heading + search bar ── */}
|
||||
@@ -83,7 +75,6 @@ export default function Home() {
|
||||
<SearchBar
|
||||
value={searchQuery}
|
||||
onChange={(q) => {
|
||||
if (q && activeCategory !== "all") setActiveCategory("all");
|
||||
setSearchQuery(q);
|
||||
}}
|
||||
onClear={() => setSearchQuery("")}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { AuthProvider } from "@/lib/auth-context";
|
||||
import { CartProvider } from "@/lib/cart-context";
|
||||
import { MenuProvider } from "@/lib/menu-context";
|
||||
|
||||
/**
|
||||
* Client-side providers wrapper.
|
||||
@@ -12,9 +11,7 @@ import { MenuProvider } from "@/lib/menu-context";
|
||||
export function Providers({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<AuthProvider>
|
||||
<MenuProvider>
|
||||
<CartProvider>{children}</CartProvider>
|
||||
</MenuProvider>
|
||||
</AuthProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user