"use client"; import { useState } from "react"; import { AlertTriangle } from "lucide-react"; import { useOfflineStatus } from "@/hooks/use-offline-status"; import { ReviewFailedDialog } from "./ReviewFailedDialog"; /** * The offline banner (TASK-0095 R2): top, below the topbar, `role=status` — * "You're offline — changes are saved on this device" + the pending count * (the CRDT-pending + outbox SUM — `computeOfflineStatus.pendingCount`) + a * "Review failed changes" link (when the failed list is non-empty). * * Visible when `navigator.onLine` is false OR the provider is `offline` OR it * has been `reconnecting` ≥ 5 s (a < 5 s blip shows no banner — only the * StatusChip flashes). Dismisses automatically when back online. */ export function OfflineBanner() { const status = useOfflineStatus(); const [reviewOpen, setReviewOpen] = useState(false); if (!status.bannerVisible) return null; return ( <>
You're offline — changes are saved on this device {status.pendingCount > 0 ? ( <> {" "} · {status.pendingCount}{" "} pending ) : null} {status.showReviewLink ? ( ) : null}
{reviewOpen ? setReviewOpen(false)} /> : null} ); }