/* * Copyright (c) 2021 - 2024, Ludvig Lundgren and the autobrr contributors. * SPDX-License-Identifier: GPL-2.0-or-later */ import toast from "react-hot-toast"; import { useMutation, useQuery } from "@tanstack/react-query"; import { useRouter } from "@tanstack/react-router"; import { Disclosure, DisclosureButton } from "@headlessui/react"; import { Bars3Icon, XMarkIcon, MegaphoneIcon } from "@heroicons/react/24/outline"; import { APIClient } from "@api/APIClient"; import Toast from "@components/notifications/Toast"; import { LeftNav } from "./LeftNav"; import { RightNav } from "./RightNav"; import { MobileNav } from "./MobileNav"; import { ExternalLink } from "@components/ExternalLink"; import { ConfigQueryOptions, UpdatesQueryOptions } from "@api/queries"; import { AuthContext } from "@utils/Context"; export const Header = () => { const router = useRouter() const { isError:isConfigError, error: configError, data: config } = useQuery(ConfigQueryOptions(true)); if (isConfigError) { console.log(configError); } const { isError: isUpdateError, error, data } = useQuery(UpdatesQueryOptions(config?.check_for_updates === true)); if (isUpdateError) { console.log("update error", error); } const logoutMutation = useMutation({ mutationFn: APIClient.auth.logout, onSuccess: () => { toast.custom((t) => ( )); AuthContext.reset(); router.history.push("/"); }, onError: (err) => { console.error("logout error", err) } }); return ( {({ open }) => ( <>
{/* Mobile menu button */} Open main menu {open ? (
{data?.html_url && (
New update available! {data?.name}
)}
)}
); };