import { useState, useMemo } from 'react'; import { useNavigate, useRouter, useLocation } from '@tanstack/react-router'; import { IconHome, IconSearch, IconUsers, IconKey, IconMessages, IconSettings, IconChartBar, IconShield, IconPlayerPlay, IconHelpCircle, IconArrowLeft, IconExternalLink, } from '@tabler/icons-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; interface SuggestedPage { title: string; description: string; path: string; icon: React.ReactNode; keywords: string[]; } export default function NotFoundError() { const navigate = useNavigate(); const { history } = useRouter(); const location = useLocation(); const [searchQuery, setSearchQuery] = useState(''); const suggestedPages: SuggestedPage[] = [ { title: 'Dashboard', description: 'Overview of your AxonHub instance', path: '/', icon: , keywords: ['dashboard', 'home', 'overview', 'main'], }, { title: 'Channels', description: 'Manage AI model channels and configurations', path: '/channels', icon: , keywords: ['channels', 'models', 'ai', 'configuration', 'chat'], }, { title: 'Requests', description: 'Monitor API requests and usage analytics', path: '/requests', icon: , keywords: ['requests', 'api', 'analytics', 'monitoring', 'usage'], }, { title: 'Users', description: 'User management and permissions', path: '/users', icon: , keywords: ['users', 'people', 'accounts', 'management'], }, { title: 'API Keys', description: 'Generate and manage API authentication keys', path: '/api-keys', icon: , keywords: ['api', 'keys', 'authentication', 'tokens', 'access'], }, { title: 'Roles', description: 'Configure user roles and permissions', path: '/roles', icon: , keywords: ['roles', 'permissions', 'access', 'security', 'rbac'], }, { title: 'Playground', description: 'Test and experiment with AI models', path: '/playground', icon: , keywords: ['playground', 'test', 'experiment', 'try', 'demo'], }, { title: 'Settings', description: 'System configuration and preferences', path: '/settings', icon: , keywords: ['settings', 'configuration', 'preferences', 'system'], }, { title: 'Help Center', description: 'Documentation and support resources', path: '/help-center', icon: , keywords: ['help', 'documentation', 'support', 'guide', 'docs'], }, ]; // Smart suggestions based on current URL and search query const smartSuggestions = useMemo(() => { const currentPath = location.pathname.toLowerCase(); const query = searchQuery.toLowerCase(); // Score pages based on URL similarity and search relevance const scoredPages = suggestedPages.map((page) => { let score = 0; // URL path similarity const pathSegments = currentPath.split('/').filter(Boolean); const pageSegments = page.path.split('/').filter(Boolean); pathSegments.forEach((segment) => { if (page.path.includes(segment) || page.keywords.some((k) => k.includes(segment))) { score += 3; } }); // Search query relevance if (query) { if (page.title.toLowerCase().includes(query)) score += 5; if (page.description.toLowerCase().includes(query)) score += 3; page.keywords.forEach((keyword) => { if (keyword.includes(query)) score += 2; }); } return { ...page, score }; }); // Sort by score and return top suggestions return scoredPages.sort((a, b) => b.score - a.score).slice(0, query ? 6 : 4); }, [location.pathname, searchQuery, suggestedPages]); const handlePageNavigation = (path: string) => { navigate({ to: path }); }; return (
{/* Header Section */}

404

Page Not Found

The page you're looking for doesn't exist, but we can help you find what you need.

{/* Search Section */}

Find what you're looking for

setSearchQuery(e.target.value)} className='pl-10' />
{/* Suggested Pages */}

{searchQuery ? 'Search Results' : 'Suggested Pages'}

{smartSuggestions.map((page) => ( handlePageNavigation(page.path)} >
{page.icon}

{page.title}

{page.description}

))}
{/* Action Buttons */}
{/* Additional Help */}

Still can't find what you're looking for?

); }