'use client'; import { useState, useEffect } from 'react'; interface Insight { id: string; content: string; metadata: { category?: string; severity?: string; confidence?: number; }; } interface Recommendation { id: string; type: string; title: string; description: string; priority: string; confidence: number; suggestedActions: string[]; } interface KnowledgePanelProps { entityId?: string; entityType?: 'aircraft' | 'audit' | 'risk'; onInsightClick?: (insight: Insight) => void; } export default function KnowledgePanel({ entityId, entityType, onInsightClick }: KnowledgePanelProps) { const [insights, setInsights] = useState([]); const [recommendations, setRecommendations] = useState([]); const [loading, setLoading] = useState(false); const [activeTab, setActiveTab] = useState<'insights' | 'recommendations'>('insights'); useEffect(() => { if (entityId && entityType) { loadKnowledge(); } }, [entityId, entityType]); const loadKnowledge = async () => { setLoading(true); try { // Модуль нормативной базы (knowledge) вынесен в отдельный сервис setInsights([]); setRecommendations([]); } catch (error) { console.error('Knowledge module in separate service', error); } finally { setLoading(false); } }; return (
{loading ? (
Анализ данных...
) : activeTab === 'insights' ? (
{insights.length === 0 ? (
Инсайты не найдены
) : ( insights.map((insight) => (
onInsightClick?.(insight)} style={{ padding: '12px', backgroundColor: '#f5f5f5', borderRadius: '4px', cursor: onInsightClick ? 'pointer' : 'default', borderLeft: `4px solid ${ insight.metadata.severity === 'high' ? '#f44336' : insight.metadata.severity === 'medium' ? '#ff9800' : '#4caf50' }`, }} >
{insight.content}
{insight.metadata.confidence && (
Уверенность: {Math.round(insight.metadata.confidence * 100)}%
)}
)) )}
) : (
{recommendations.length === 0 ? (
Рекомендации не найдены
) : ( recommendations.map((rec) => (
{rec.title}
{rec.description}
{rec.suggestedActions.length > 0 && (
Рекомендуемые действия:
    {rec.suggestedActions.map((action, idx) => (
  • {action}
  • ))}
)}
)) )}
)}
); }