Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/app/[country]/[locale]/(storefront)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ export default async function StorefrontLayout({
.then((res) => res.data)
.catch(() => []);

const menuCategories = rootCategories.flatMap((root) => root.children ?? []);

return (
<>
<Header rootCategories={rootCategories} />
{menuCategories.length > 0 && (
{rootCategories.length > 0 && (
<nav aria-label="Category navigation" className="sr-only">
<CategoryLinks categories={menuCategories} basePath={basePath} />
<CategoryLinks categories={rootCategories} basePath={basePath} />
</nav>
)}
<main className="flex-1">{children}</main>
Expand Down
70 changes: 26 additions & 44 deletions src/components/layout/MobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import type { Category } from "@spree/sdk";
import { ArrowLeft, Check, ChevronRight, User, X } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useRef, useState } from "react";
import { flushSync } from "react-dom";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -46,7 +45,6 @@ export function MobileMenu({ rootCategories, basePath }: MobileMenuProps) {
const timeoutRef = useRef<NodeJS.Timeout | null>(null);

const { country, currency, countries } = useStore();
const router = useRouter();
const { isCountryNavigating, handleCountrySelect } = useCountrySwitch({
currentCountry: country,
onBeforeNavigate: () => setOpen(false),
Expand Down Expand Up @@ -98,14 +96,6 @@ export function MobileMenu({ rootCategories, basePath }: MobileMenuProps) {
}
};

const handleNavigate = (href: string) => {
setOpen(false);
router.push(href);
};

// Flatten root categories: show their children directly instead of taxonomy names
const menuCategories = rootCategories.flatMap((root) => root.children ?? []);

// Shared link style
const linkClass =
"text-left text-gray-700 hover:text-gray-900 hover:bg-gray-50 rounded-lg px-3 py-2.5 text-base transition-colors";
Expand Down Expand Up @@ -225,21 +215,21 @@ export function MobileMenu({ rootCategories, basePath }: MobileMenuProps) {
}`}
>
<nav className="flex flex-col gap-1 px-4 flex-1 overflow-y-auto pt-2">
<button
type="button"
onClick={() => handleNavigate(basePath || "/")}
<Link
href={basePath || "/"}
onClick={() => setOpen(false)}
className={linkClass}
>
Home
</button>
<button
type="button"
onClick={() => handleNavigate(`${basePath}/products`)}
</Link>
<Link
href={`${basePath}/products`}
onClick={() => setOpen(false)}
className={linkClass}
>
All Products
</button>
{menuCategories.map((category) =>
</Link>
{rootCategories.map((category) =>
category.children && category.children.length > 0 ? (
<button
key={category.id}
Expand All @@ -251,25 +241,23 @@ export function MobileMenu({ rootCategories, basePath }: MobileMenuProps) {
<ChevronRight className="w-4 h-4 text-gray-400" />
</button>
) : (
<button
<Link
key={category.id}
type="button"
onClick={() =>
handleNavigate(`${basePath}/c/${category.permalink}`)
}
href={`${basePath}/c/${category.permalink}`}
onClick={() => setOpen(false)}
className={linkClass}
>
{category.name}
</button>
</Link>
),
)}
<button
type="button"
onClick={() => handleNavigate(`${basePath}/#contact`)}
<Link
href={`${basePath}/#contact`}
onClick={() => setOpen(false)}
className={linkClass}
>
Contact
</button>
</Link>
</nav>

{/* Footer: Country switcher (mobile + tablet) + Account (mobile only) */}
Expand Down Expand Up @@ -342,33 +330,27 @@ export function MobileMenu({ rootCategories, basePath }: MobileMenuProps) {
<ChevronRight className="w-4 h-4 text-gray-400" />
</button>
) : (
<button
<Link
key={child.id}
type="button"
onClick={() =>
handleNavigate(`${basePath}/c/${child.permalink}`)
}
href={`${basePath}/c/${child.permalink}`}
onClick={() => handleOpenChange(false)}
className={linkClass}
>
{child.name}
</button>
</Link>
),
)}
</nav>

{/* "View all" at the bottom */}
<div className="border-t border-gray-200 px-4 py-3">
<button
type="button"
onClick={() =>
handleNavigate(
`${basePath}/c/${panel.category.permalink}`,
)
}
className="w-full text-center text-sm text-gray-500 hover:text-gray-900 py-2 transition-colors"
<Link
href={`${basePath}/c/${panel.category.permalink}`}
onClick={() => handleOpenChange(false)}
className="block w-full text-center text-sm text-gray-500 hover:text-gray-900 py-2 transition-colors"
>
View all {panel.category.name}
</button>
</Link>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
</div>
</div>
);
Expand Down
25 changes: 13 additions & 12 deletions src/components/products/filters/ProductFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,21 @@ export const FilterBar = memo(function FilterBar({

const activeSortBy = activeFilters.sortBy || filtersData?.default_sort;

if (filtersLoading) {
return (
<div className="flex items-center gap-3 mb-4 pb-4 border-b border-gray-200">
<div className="h-10 w-20 bg-gray-200 rounded-lg animate-pulse" />
<div className="h-10 w-18 bg-gray-200 rounded-lg animate-pulse" />
<div className="h-10 w-18 bg-gray-200 rounded-lg animate-pulse" />
<div className="h-10 w-24 bg-gray-200 rounded-lg animate-pulse" />
<div className="ml-auto h-10 w-18 bg-gray-200 rounded-lg animate-pulse" />
</div>
);
if (!filtersData) {
if (filtersLoading) {
return (
<div className="flex items-center gap-3 mb-4 pb-4 border-b border-gray-200">
<div className="h-10 w-20 bg-gray-200 rounded-lg animate-pulse" />
<div className="h-10 w-18 bg-gray-200 rounded-lg animate-pulse" />
<div className="h-10 w-18 bg-gray-200 rounded-lg animate-pulse" />
<div className="h-10 w-24 bg-gray-200 rounded-lg animate-pulse" />
<div className="ml-auto h-10 w-18 bg-gray-200 rounded-lg animate-pulse" />
</div>
);
}
return null;
}

if (!filtersData) return null;

const availabilityFilter = filtersData.filters.find(
(f) => f.type === "availability",
) as AvailabilityFilter | undefined;
Expand Down
Loading