novyie parvki
This commit is contained in:
@ -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 })
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user