'use client' import { useState, useEffect } from 'react' interface OfflineIndicatorProps { className?: string } export default function OfflineIndicator({ className = '' }: OfflineIndicatorProps) { const [isOffline, setIsOffline] = useState(false) const [showRetry, setShowRetry] = useState(false) useEffect(() => { const handleOnline = () => { setIsOffline(false) setShowRetry(false) } const handleOffline = () => { setIsOffline(true) // Show retry button after 5 seconds setTimeout(() => setShowRetry(true), 5000) } // Check initial state if (!navigator.onLine) { setIsOffline(true) setShowRetry(true) } window.addEventListener('online', handleOnline) window.addEventListener('offline', handleOffline) return () => { window.removeEventListener('online', handleOnline) window.removeEventListener('offline', handleOffline) } }, []) if (!isOffline) return null const handleRetry = () => { // Try to refresh the page window.location.reload() } return (
Some features may be limited. We'll reconnect automatically when you're back online.
{showRetry && ( )}