import { useState } from 'react'; import { useParams, Link } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { apiFetch } from '../lib/api'; import { useI18n } from '../lib/i18n'; import DocPreview from './tabs/DocPreview'; import ModuleManagement from './tabs/ModuleManagement'; import McpIntegration from './tabs/McpIntegration'; import ProjectSettings from './tabs/ProjectSettings'; import Badge from '../components/Badge'; import Skeleton from '../components/Skeleton'; type ProjectData = { id: string; name: string; description: string | null; baseUrl: string | null; openApiVersion: string; modules: Array<{ id: string; name: string; description: string | null; _count: { endpoints: number } }>; _count: { endpoints: number; modules: number }; }; const tabs = [ { key: 'mcp', labelKey: 'dashboard.projectDetail.tabMcp', icon: 'M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1' }, { key: 'docs', labelKey: 'dashboard.projectDetail.tabDocs', icon: 'M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z' }, { key: 'modules', labelKey: 'dashboard.projectDetail.tabModules', icon: 'M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10' }, { key: 'settings', labelKey: 'dashboard.projectDetail.tabSettings', icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z' }, ] as const; type TabKey = (typeof tabs)[number]['key']; export default function ProjectDetail() { const { id } = useParams<{ id: string }>(); const [activeTab, setActiveTab] = useState('mcp'); const { t } = useI18n(); const { data: project, isLoading } = useQuery({ queryKey: ['project', id], queryFn: () => apiFetch(`/projects/${id}`), }); if (isLoading) { return (
); } if (!project) { return (

{t('dashboard.projectDetail.notFound')}

{t('dashboard.projectDetail.backToProjects')}
); } return (
{/* Breadcrumb */}
{t('dashboard.projectDetail.breadcrumbProjects')} {project.name}
{/* Header */}

{project.name}

{project.description &&

{project.description}

}
OpenAPI {project.openApiVersion} {project._count.endpoints} {t('common.endpoints')}
{/* Tabs */}
{tabs.map((tab) => ( ))}
{/* Content */}
{activeTab === 'docs' && } {activeTab === 'modules' && } {activeTab === 'mcp' && } {activeTab === 'settings' && }
); }