"use client";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { useSiteContext } from "@app/hooks/useSiteContext";
import {
InfoSection,
InfoSectionContent,
InfoSections,
InfoSectionTitle
} from "@app/components/InfoSection";
import { useTranslations } from "next-intl";
import { countryCodeToFlagEmoji } from "@app/lib/countryCodeToFlagEmoji";
type SiteInfoCardProps = {};
function formatPublicEndpoint(endpoint: string) {
return endpoint.includes(":")
? endpoint.substring(0, endpoint.lastIndexOf(":"))
: endpoint;
}
export default function SiteInfoCard({}: SiteInfoCardProps) {
const { site } = useSiteContext();
const t = useTranslations();
const identifierSection = (
{t("identifier")}{site.niceId}
);
const statusSection = (
{t("status")}
{site.online ? (
{t("online")}
) : (
{t("offline")}
)}
);
const endpointSection = site.endpoint ? (
{t("publicIpEndpoint")}
{formatPublicEndpoint(site.endpoint)}
{site.countryCode &&
countryCodeToFlagEmoji(site.countryCode)}
) : null;
if (site.type === "newt") {
// agent and agentVersion were added after newtVersion, so a
// site still running an older Newt reports only newtVersion.
// Without these fallbacks the badge renders with no label and
// no version at all.
const agentLabel = site.agent == "cli" ? "Pangolin CLI" : "Newt";
const agentVersion = site.agentVersion ?? site.newtVersion;
return (
{statusSection}
{t("connectionType")}
{t("pangolinSite")}
{t("agent")}