import ServerFlag from "@/components/ServerFlag" import ServerUsageBar from "@/components/ServerUsageBar" import { formatBytes } from "@/lib/format" import { GetFontLogoClass, GetOsName, MageMicrosoftWindows } from "@/lib/logo-class" import { cn, formatNezhaInfo, parsePublicNote } from "@/lib/utils" import { NezhaServer } from "@/types/nezha-api" import { useTranslation } from "react-i18next" import { useNavigate } from "react-router-dom" import PlanInfo from "./PlanInfo" import BillingInfo from "./billingInfo" import { Card } from "./ui/card" import { Separator } from "./ui/separator" export default function ServerCardInline({ now, serverInfo }: { now: number; serverInfo: NezhaServer }) { const { t } = useTranslation() const navigate = useNavigate() const { name, country_code, online, cpu, up, down, mem, stg, platform, uptime, net_in_transfer, net_out_transfer, public_note } = formatNezhaInfo( now, serverInfo, ) const showFlag = true const customBackgroundImage = // @ts-expect-error CustomBackgroundImage is a global variable (window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined const parsedData = parsePublicNote(public_note) return online ? (
navigate(`/server/${serverInfo.id}`)} >
{showFlag ? : null}

{name}

{parsedData?.billingDataMod && }
{platform.includes("Windows") ? ( ) : (

)}

{t("serverCard.system")}

{platform.includes("Windows") ? "Windows" : GetOsName(platform)}

{t("serverCard.uptime")}

{uptime / 86400 >= 1 ? `${(uptime / 86400).toFixed(0)} ${t("serverCard.days")}` : `${(uptime / 3600).toFixed(0)} ${t("serverCard.hours")}`}

{"CPU"}

{cpu.toFixed(2)}%

{t("serverCard.mem")}

{mem.toFixed(2)}%

{t("serverCard.stg")}

{stg.toFixed(2)}%

{t("serverCard.upload")}

{up >= 1024 ? `${(up / 1024).toFixed(2)}G/s` : up >= 1 ? `${up.toFixed(2)}M/s` : `${(up * 1024).toFixed(2)}K/s`}

{t("serverCard.download")}

{down >= 1024 ? `${(down / 1024).toFixed(2)}G/s` : up >= 1 ? `${down.toFixed(2)}M/s` : `${(down * 1024).toFixed(2)}K/s`}

{t("serverCard.totalUpload")}

{formatBytes(net_out_transfer)}

{t("serverCard.totalDownload")}

{formatBytes(net_in_transfer)}
{parsedData?.planDataMod && }
) : ( navigate(`/server/${serverInfo.id}`)} >
{showFlag ? : null}

{name}

{parsedData?.billingDataMod && }
{parsedData?.planDataMod && }
) }