fix: bug
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { useState, useMemo, useCallback, useEffect } from 'react'
|
||||
import { CategoryTemplate } from '@repo/sdk'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
export interface Category {
|
||||
id: string
|
||||
name: string
|
||||
nameEn?: string
|
||||
templates?: CategoryTemplate[]
|
||||
}
|
||||
|
||||
@@ -23,6 +25,7 @@ export interface UseTabNavigationReturn {
|
||||
|
||||
export function useTabNavigation(options: UseTabNavigationOptions): UseTabNavigationReturn {
|
||||
const { categories, initialCategoryId } = options
|
||||
const { i18n } = useTranslation()
|
||||
|
||||
// State for active tab index
|
||||
const [activeIndex, setActiveIndex] = useState<number>(() => {
|
||||
@@ -52,10 +55,14 @@ export function useTabNavigation(options: UseTabNavigationOptions): UseTabNaviga
|
||||
}
|
||||
}, [categories, selectedCategoryId])
|
||||
|
||||
// Generate tabs array from category names
|
||||
// Generate tabs array from category names with i18n support
|
||||
const tabs = useMemo(() => {
|
||||
return categories.map(category => category.name)
|
||||
}, [categories])
|
||||
const isEnglish = i18n.language === 'en-US'
|
||||
return categories.map(category => {
|
||||
// Use English name if available and language is English, otherwise use Chinese name
|
||||
return isEnglish && category.nameEn ? category.nameEn : category.name
|
||||
})
|
||||
}, [categories, i18n.language])
|
||||
|
||||
// Get current category based on selectedCategoryId
|
||||
const currentCategory = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user