'use client'; import Link from 'next/link'; import { usePathname, useSearchParams } from 'next/navigation'; import { Clock3, ListTodo } from 'lucide-react'; import { pickAppText } from '@/lib/i18n/core'; import { useAppI18n } from '@/lib/i18n/provider'; import { cn } from '@/lib/utils'; const TASK_MANAGEMENT_TABS = [ { label: 'ordinary', href: '/tasks', icon: ListTodo, match: (pathname: string, tab: string | null) => pathname.startsWith('/tasks') && tab !== 'scheduled', }, { label: 'scheduled', href: '/tasks?tab=scheduled', icon: Clock3, match: (pathname: string, tab: string | null) => pathname.startsWith('/tasks') && tab === 'scheduled', }, ] as const; export function TaskManagementTabs() { const { locale } = useAppI18n(); const pathname = usePathname(); const searchParams = useSearchParams(); const activeTab = searchParams.get('tab'); return (
{TASK_MANAGEMENT_TABS.map((tab) => { const isActive = tab.match(pathname, activeTab); const Icon = tab.icon; return ( {tab.label === 'scheduled' ? pickAppText(locale, '定时任务', 'Scheduled tasks') : pickAppText(locale, '普通任务', 'Ordinary tasks')} ); })}
); }