novyie parvki

This commit is contained in:
54CHA
2025-07-30 15:25:18 +03:00
parent 9adc737028
commit 80ed5826e2
5 changed files with 46 additions and 18 deletions

View File

@ -3,10 +3,17 @@ import { useQuery } from '@apollo/client';
import { GET_PARTSINDEX_CATEGORIES } from '@/lib/graphql';
import { useRouter } from 'next/router';
interface CategoryNavGroup {
id: string;
name: string;
image?: string;
}
interface CategoryNavItem {
id: string;
name: string;
image?: string;
groups?: CategoryNavGroup[];
}
const FALLBACK_CATEGORIES: CategoryNavItem[] = [
@ -38,11 +45,15 @@ const CategoryNavSection: React.FC = () => {
: FALLBACK_CATEGORIES;
const handleCategoryClick = (category: CategoryNavItem) => {
// Получаем первую доступную группу для навигации в PartsIndex режим
const firstGroupId = category.groups && category.groups.length > 0 ? category.groups[0].id : undefined;
router.push({
pathname: '/catalog',
query: {
categoryId: category.id,
categoryName: encodeURIComponent(category.name)
partsIndexCatalog: category.id,
categoryName: encodeURIComponent(category.name),
...(firstGroupId && { partsIndexCategory: firstGroupId })
}
});
};