'use client'; import { Alert, Snackbar, Box, Typography, CircularProgress } from '@mui/material'; import { CloudOff, CloudQueue, CloudDone, Wifi, WifiOff } from '@mui/icons-material'; import { useIsOnline, useSyncStatus } from '@/store/hooks'; export const NetworkStatusIndicator: React.FC = () => { const isOnline = useIsOnline(); const { syncing, pendingCount } = useSyncStatus(); // Show nothing if online and no pending sync if (isOnline && !syncing && pendingCount === 0) { return null; } return ( ) : isOnline ? ( ) : ( ) } sx={{ width: '100%', maxWidth: 400, borderRadius: 2, }} > {!isOnline && 'You are offline'} {isOnline && syncing && 'Syncing changes...'} {isOnline && !syncing && pendingCount > 0 && `${pendingCount} changes pending`} {!isOnline && 'Your changes will be saved and synced when you reconnect'} {isOnline && syncing && 'Please wait while we sync your data'} {isOnline && !syncing && pendingCount > 0 && 'Waiting to sync'} ); }; /** * Small status badge for the app bar */ export const NetworkStatusBadge: React.FC = () => { const isOnline = useIsOnline(); const { syncing, pendingCount } = useSyncStatus(); if (isOnline && !syncing && pendingCount === 0) { return null; } return ( {syncing ? ( ) : isOnline ? ( ) : ( )} {!isOnline && 'Offline'} {isOnline && syncing && 'Syncing'} {isOnline && !syncing && pendingCount > 0 && pendingCount} ); };