'use client' import { useOfflineSync } from '@/hooks' import { WifiOff, Wifi, RefreshCw, AlertCircle } from 'lucide-react' /** * Offline indicator component * Shows connection status and sync progress * Validates: Requirements 4.5 */ export default function OfflineIndicator() { const { isOnline, isSyncing, syncError, queueLength, triggerSync } = useOfflineSync() // Don't show anything if online and no pending syncs if (isOnline && queueLength === 0 && !syncError) { return null } return (
0 ? 'bg-blue-600 text-white' : ''} ${syncError ? 'bg-red-600 text-white' : ''} `} > {/* Icon */} {!isOnline && } {isOnline && !syncError && } {syncError && } {/* Status text */}
{!isOnline && ( <> Offline {queueLength > 0 && ( {queueLength} change{queueLength !== 1 ? 's' : ''} pending )} )} {isOnline && isSyncing && ( <> Syncing... {queueLength} change{queueLength !== 1 ? 's' : ''} remaining )} {isOnline && !isSyncing && queueLength > 0 && !syncError && ( <> Ready to sync {queueLength} change{queueLength !== 1 ? 's' : ''} pending )} {syncError && ( <> Sync failed {syncError.message} )}
{/* Sync button */} {isOnline && queueLength > 0 && !isSyncing && ( )} {/* Syncing spinner */} {isSyncing && ( )}
) }