import { useAuth } from "@/hooks/useAuth"; import { Button } from "@/components/ui/button"; import { ModeToggle } from "@/components/theme/ModeToggle"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; import { toast } from "sonner"; import { Skeleton } from "@/components/ui/skeleton"; import { useLiveRefresh } from "@/hooks/useLiveRefresh"; import { useConfigStatus } from "@/hooks/useConfigStatus"; import { Menu, LogOut } from "lucide-react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; interface HeaderProps { currentPage?: "dashboard" | "repositories" | "organizations" | "configuration" | "activity-log"; onNavigate?: (page: string) => void; onMenuClick: () => void; } export function Header({ currentPage, onNavigate, onMenuClick }: HeaderProps) { const { user, logout, isLoading } = useAuth(); const { isLiveEnabled, toggleLive } = useLiveRefresh(); const { isFullyConfigured, isLoading: configLoading } = useConfigStatus(); // Show Live button on all pages except configuration const showLiveButton = currentPage && currentPage !== "configuration"; // Determine button state and tooltip const isLiveActive = isLiveEnabled && isFullyConfigured; const getTooltip = () => { if (configLoading) { return 'Loading configuration...'; } if (!isFullyConfigured) { return isLiveEnabled ? 'Live refresh enabled but requires GitHub and Gitea configuration to function' : 'Enable live refresh (requires GitHub and Gitea configuration)'; } return isLiveEnabled ? 'Disable live refresh' : 'Enable live refresh'; }; const handleLogout = async () => { toast.success("Logged out successfully"); // Small delay to show the toast before redirecting await new Promise((resolve) => setTimeout(resolve, 500)); logout(); }; // Auth buttons skeleton loader function AuthButtonsSkeleton() { return ( <> {/* Avatar placeholder */} {/* Button placeholder */} > ); } return ( {/* Hamburger Menu Button - Mobile Only */} Toggle menu { if (currentPage !== 'dashboard') { window.history.pushState({}, '', '/'); onNavigate?.('dashboard'); } }} className="flex items-center gap-2 py-1 hover:opacity-80 transition-opacity" > Gitea Mirror {showLiveButton && ( LIVE )} {isLoading ? ( ) : user ? ( {user.username.charAt(0).toUpperCase()} Logout ) : ( Login )} ); }