import React from 'react';
import { Link } from 'react-router-dom';
import { useAuth } from '@/contexts/AuthContext';
import { useForum } from '@/contexts/ForumContext';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { ShieldCheck, LogOut, Terminal, Wifi, WifiOff, Eye, MessageSquare, RefreshCw, Key } from 'lucide-react';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
const Header = () => {
const {
currentUser,
isAuthenticated,
verificationStatus,
connectWallet,
disconnectWallet,
verifyOrdinal,
delegateKey,
isDelegationValid,
delegationTimeRemaining
} = useAuth();
const { isNetworkConnected, isRefreshing } = useForum();
const handleConnect = async () => {
await connectWallet();
};
const handleDisconnect = () => {
disconnectWallet();
};
const handleVerify = async () => {
await verifyOrdinal();
};
const handleDelegateKey = async () => {
await delegateKey();
};
// Format delegation time remaining for display
const formatDelegationTime = () => {
if (!isDelegationValid()) return null;
const timeRemaining = delegationTimeRemaining();
const hours = Math.floor(timeRemaining / (1000 * 60 * 60));
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
return `${hours}h ${minutes}m`;
};
const renderDelegationButton = () => {
// Only show delegation button for verified Ordinal owners
if (verificationStatus !== 'verified-owner') return null;
const hasValidDelegation = isDelegationValid();
const timeRemaining = formatDelegationTime();
return (
You have a delegated browser key active for {timeRemaining}.
You won't need to sign messages with your wallet for most actions. Delegate a browser key to avoid signing every action with your wallet.
Improves UX by reducing wallet popups for 24 hours.
Wallet Verified - No Ordinals Found
Your wallet has been verified but does not contain any Ordinal Operators.
You can browse content but cannot post, comment, or vote.
Verify again
Ordinal Operators Verified!
You have full forum access with permission to post, comment, and vote.
Verify again
{isNetworkConnected ? "Connected to Waku network" : "Not connected to Waku network. Some features may be unavailable."}
{isRefreshing &&Refreshing data...
}