import { RefreshCw, Wifi, WifiOff, AlertCircle } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; type ConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error'; interface RealtimeConnectionStatusProps { connectionState: ConnectionState; onReconnect: () => void; className?: string; } export function RealtimeConnectionStatus({ connectionState, onReconnect, className = '', }: RealtimeConnectionStatusProps) { const getStatusConfig = () => { switch (connectionState) { case 'connected': return { icon: Wifi, color: 'text-green-500', label: 'Connected', description: 'Live updates active', showReconnect: false, }; case 'connecting': return { icon: RefreshCw, color: 'text-yellow-500', label: 'Connecting', description: 'Establishing connection...', showReconnect: false, animate: 'animate-spin', }; case 'error': return { icon: AlertCircle, color: 'text-red-500', label: 'Error', description: 'Connection failed. Retrying...', showReconnect: true, }; case 'disconnected': return { icon: WifiOff, color: 'text-muted-foreground', label: 'Disconnected', description: 'Live updates unavailable', showReconnect: true, }; default: return { icon: WifiOff, color: 'text-muted-foreground', label: 'Unknown', description: 'Connection status unknown', showReconnect: true, }; } }; const config = getStatusConfig(); const Icon = config.icon; return (
{config.label}

{config.description}

{config.showReconnect && ( )}
); }