import { ArrowDownCircleIcon, ArrowUpCircleIcon, } from "@heroicons/react/20/solid"; import { useTranslation } from "react-i18next"; import { Card, CardContent } from "@/components/ui/card"; import { useStatus } from "@/hooks/use-status"; import { formatBytes } from "@/lib/format"; import { cn } from "@/lib/utils"; import NumericText from "./NumericText"; type ServerOverviewProps = { online: number; offline: number; total: number; up: number; down: number; upSpeed: number; downSpeed: number; }; export default function ServerOverview({ online, offline, total, up, down, upSpeed, downSpeed, }: ServerOverviewProps) { const { t } = useTranslation(); const { status, setStatus } = useStatus(); // @ts-expect-error DisableAnimatedMan is a global variable const disableAnimatedMan = window.DisableAnimatedMan as boolean; // @ts-expect-error CustomIllustration is a global variable const customIllustration = window.CustomIllustration || "/animated-man.webp"; const customBackgroundImage = (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined; return (
{ setStatus("all"); }} className={cn( "group cursor-pointer transition-all hover:ring-blue-500 dark:hover:ring-blue-600", { "bg-card/70": customBackgroundImage, }, )} >

{t("serverOverview.totalServers")}

{ setStatus("online"); }} className={cn( "cursor-pointer ring-1 transition-all hover:ring-green-500 dark:hover:ring-green-600", { "bg-card/70": customBackgroundImage, }, { "border-transparent ring-2 ring-green-500 dark:ring-green-600": status === "online", }, )} >

{t("serverOverview.onlineServers")}

{ setStatus("offline"); }} className={cn( "cursor-pointer ring-1 transition-all hover:ring-red-500 dark:hover:ring-red-600", { "bg-card/70": customBackgroundImage, }, { "border-transparent ring-2 ring-red-500 dark:ring-red-600": status === "offline", }, )} >

{t("serverOverview.offlineServers")}

{t("serverOverview.network")}

{formatBytes(upSpeed)}/s

{formatBytes(downSpeed)}/s

{!disableAnimatedMan && ( {"animated-man"} )}
); }