"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";
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 ? (
) : (
)}
);
const endpointSection = site.endpoint ? (
{t("publicIpEndpoint")}
{formatPublicEndpoint(site.endpoint)}
) : null;
if (site.type === "newt") {
return (
{identifierSection}
{statusSection}
{t("connectionType")}
Newt
{t("newtVersion")}
{site.newtVersion
? `v${site.newtVersion}`
: "-"}
{endpointSection}
);
}
if (site.type === "wireguard") {
return (
{identifierSection}
{statusSection}
{t("connectionType")}
WireGuard
{endpointSection}
);
}
if (site.type === "local") {
return (
{identifierSection}
{t("connectionType")}
{t("local")}
{endpointSection}
);
}
return (
{identifierSection}
{t("connectionType")}
{t("unknown")}
{endpointSection}
);
}