Files
neta/components/ui/offline-indicator.tsx
T

34 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect, useState } from "react";
import { WifiOff } from "lucide-react";
export function OfflineIndicator() {
const [isOnline, setIsOnline] = useState(true);
useEffect(() => {
// Sadece client-side'da çalışır
setIsOnline(navigator.onLine);
const handleOnline = () => setIsOnline(true);
const handleOffline = () => setIsOnline(false);
window.addEventListener("online", handleOnline);
window.addEventListener("offline", handleOffline);
return () => {
window.removeEventListener("online", handleOnline);
window.removeEventListener("offline", handleOffline);
};
}, []);
if (isOnline) return null;
return (
<div className="fixed bottom-4 right-4 z-50 flex items-center gap-2 rounded-lg bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground shadow-lg animate-in fade-in slide-in-from-bottom-4">
<WifiOff className="h-4 w-4" />
Çevrimdışı moddasınız. Değişiklikler senkronize edilmeyecek.
</div>
);
}