import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Leaf, Download, Wifi, WifiOff } from "lucide-react"; import { useToast } from "@/hooks/use-toast"; import { useOfflineStatus } from "@/hooks/useOfflineStatus"; import logoImage from "@assets/ChatGPT Image Jun 6, 2025, 02_19_36 PM.png"; export default function PWAHeader() { const [deferredPrompt, setDeferredPrompt] = useState(null); const { toast } = useToast(); const isOffline = useOfflineStatus(); useEffect(() => { const handleBeforeInstallPrompt = (e: any) => { e.preventDefault(); setDeferredPrompt(e); }; window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt); return () => { window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt); }; }, []); const handleInstallPrompt = async () => { if (deferredPrompt) { deferredPrompt.prompt(); const { outcome } = await deferredPrompt.userChoice; if (outcome === 'accepted') { toast({ title: "App Installed!", description: "Prithvi Guardian AI is now available on your device.", }); } setDeferredPrompt(null); } else { toast({ title: "Already Installed", description: "The app is already installed or not available for installation.", }); } }; return (
Prithvi Guardian AI Logo

Prithvi Guardian AI

Environmental Engineering Assistant

A Product Of VBharat AI

{isOffline ? ( ) : ( )} {isOffline ? 'Offline Mode' : 'Offline Ready'}
); }