import React from 'react'; import { Database, CheckCircle, AlertTriangle, Loader2, Briefcase, Home, ShoppingBag, TrendingUp, Users, MessageCircle, Globe, ChevronRight } from 'lucide-react'; import { ToolViewProps } from '../types'; import { formatTimestamp } from '../utils'; import { cn } from '@/lib/utils'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { extractDataProviderEndpointsData } from './_utils'; const PROVIDER_CONFIG = { 'linkedin': { name: 'LinkedIn Data Provider', icon: Users, color: 'from-blue-500 to-blue-600', bgColor: 'bg-blue-50 dark:bg-blue-900/20', textColor: 'text-blue-700 dark:text-blue-300' }, 'twitter': { name: 'Twitter Data Provider', icon: MessageCircle, color: 'from-sky-400 to-sky-500', bgColor: 'bg-sky-50 dark:bg-sky-900/20', textColor: 'text-sky-700 dark:text-sky-300' }, 'zillow': { name: 'Zillow Data Provider', icon: Home, color: 'from-emerald-500 to-emerald-600', bgColor: 'bg-emerald-50 dark:bg-emerald-900/20', textColor: 'text-emerald-700 dark:text-emerald-300' }, 'amazon': { name: 'Amazon Data Provider', icon: ShoppingBag, color: 'from-orange-500 to-orange-600', bgColor: 'bg-orange-50 dark:bg-orange-900/20', textColor: 'text-orange-700 dark:text-orange-300' }, 'yahoo_finance': { name: 'Yahoo Finance Data Provider', icon: TrendingUp, color: 'from-purple-500 to-purple-600', bgColor: 'bg-purple-50 dark:bg-purple-900/20', textColor: 'text-purple-700 dark:text-purple-300' }, 'active_jobs': { name: 'Active Jobs Data Provider', icon: Briefcase, color: 'from-indigo-500 to-indigo-600', bgColor: 'bg-indigo-50 dark:bg-indigo-900/20', textColor: 'text-indigo-700 dark:text-indigo-300' } }; export function DataProviderEndpointsToolView({ assistantContent, toolContent, assistantTimestamp, toolTimestamp, isSuccess = true, isStreaming = false, }: ToolViewProps) { const { serviceName, endpoints, actualIsSuccess, actualToolTimestamp, actualAssistantTimestamp } = extractDataProviderEndpointsData( assistantContent, toolContent, isSuccess, toolTimestamp, assistantTimestamp ); const providerConfig = serviceName && PROVIDER_CONFIG[serviceName as keyof typeof PROVIDER_CONFIG] ? PROVIDER_CONFIG[serviceName as keyof typeof PROVIDER_CONFIG] : PROVIDER_CONFIG['linkedin']; const IconComponent = providerConfig.icon; const endpointCount = endpoints && typeof endpoints === 'object' ? Object.keys(endpoints).length : 0; return (
Data Provider
{!isStreaming && ( {actualIsSuccess ? ( ) : ( )} {actualIsSuccess ? 'Loaded' : 'Failed'} )}
{isStreaming ? (

Loading provider...

Connecting to data source

) : (

{providerConfig.name}

{endpointCount > 0 ? `${endpointCount} endpoints loaded and ready` : 'Endpoints loaded and ready'}

{actualIsSuccess ? ( ) : ( )} {actualIsSuccess ? 'Connected' : 'Failed'}
Provider Status
Connection Status
{actualIsSuccess ? ( ) : ( )} {actualIsSuccess ? 'Active' : 'Inactive'}
Endpoints Available
{endpointCount > 0 ? `${endpointCount} endpoints` : 'Ready'}
Data Provider
{serviceName || 'linkedin'}
{actualIsSuccess && (
Provider Ready

Data provider endpoints have been loaded successfully and are ready to process requests.

)}
)}
{!isStreaming && ( {providerConfig.name.split(' ')[0]} )}
{actualToolTimestamp && !isStreaming ? formatTimestamp(actualToolTimestamp) : actualAssistantTimestamp ? formatTimestamp(actualAssistantTimestamp) : ''}
); }