diff --git a/apps/masterbots.ai/components/shared/category-tabs/category-link.tsx b/apps/masterbots.ai/components/shared/category-tabs/category-link.tsx index 7c5bcb3e..51ccffca 100644 --- a/apps/masterbots.ai/components/shared/category-tabs/category-link.tsx +++ b/apps/masterbots.ai/components/shared/category-tabs/category-link.tsx @@ -5,15 +5,18 @@ import { toSlug } from '@/lib/url' export function CategoryLink({ category, - id + id, + activeTab }: { category: Category | 'all' id: string + activeTab: string }) { return ( - {/* {((activeTab === null && category === 'all') || - (category !== 'all' && activeTab === category.categoryId)) && ( + {((activeTab === 'all' && category === 'all') || + (category !== 'all' && activeTab === toSlug(category.name))) && ( - )} */} + )} {category === 'all' ? 'All' : category.name} ) diff --git a/apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx b/apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx index e7061afe..bd197af7 100644 --- a/apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx +++ b/apps/masterbots.ai/components/shared/category-tabs/category-tabs.tsx @@ -2,6 +2,8 @@ import type { Category } from '@repo/mb-genql' import { CategoryLink } from './category-link' +import { useEffect } from 'react' +import { toSlug } from '@/lib/url' export function CategoryTabs({ categories, @@ -10,11 +12,38 @@ export function CategoryTabs({ categories: Category[] initialCategory?: string }) { + useEffect(() => { + console.log('TopETH', initialCategory) + if (document) { + const element = document.getElementById( + `browse-category-tab__${ + initialCategory === 'all' + ? 'all' + : categories.filter(c => toSlug(c.name) === initialCategory)[0] + ?.categoryId + }` + ) + + if (element) { + element.scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }) + } + } + }, [initialCategory]) + return (
- + {categories.map((category, key) => (