mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-03 16:43:45 +00:00
69 lines
2.7 KiB
TypeScript
69 lines
2.7 KiB
TypeScript
"use client";
|
|
|
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import { useClientContext } from "@app/hooks/useClientContext";
|
|
import {
|
|
InfoSection,
|
|
InfoSectionContent,
|
|
InfoSections,
|
|
InfoSectionTitle
|
|
} from "@app/components/InfoSection";
|
|
import { getUserDisplayName } from "@app/lib/getUserDisplayName";
|
|
import { useTranslations } from "next-intl";
|
|
|
|
type ClientInfoCardProps = {};
|
|
|
|
export default function SiteInfoCard({}: ClientInfoCardProps) {
|
|
const { client, updateClient } = useClientContext();
|
|
const t = useTranslations();
|
|
|
|
const userDisplayName = getUserDisplayName({
|
|
email: client.userEmail,
|
|
name: client.userName,
|
|
username: client.userUsername
|
|
});
|
|
|
|
return (
|
|
<Alert>
|
|
<AlertDescription>
|
|
<InfoSections cols={4}>
|
|
<InfoSection>
|
|
<InfoSectionTitle>{t("name")}</InfoSectionTitle>
|
|
<InfoSectionContent>{client.name}</InfoSectionContent>
|
|
</InfoSection>
|
|
<InfoSection>
|
|
<InfoSectionTitle>
|
|
{userDisplayName ? t("user") : t("identifier")}
|
|
</InfoSectionTitle>
|
|
<InfoSectionContent>
|
|
{userDisplayName || client.niceId}
|
|
</InfoSectionContent>
|
|
</InfoSection>
|
|
<InfoSection>
|
|
<InfoSectionTitle>{t("status")}</InfoSectionTitle>
|
|
<InfoSectionContent>
|
|
{client.online ? (
|
|
<div className="text-green-500 flex items-center space-x-2">
|
|
<div className="w-2 h-2 bg-green-500 rounded-full"></div>
|
|
<span>{t("online")}</span>
|
|
</div>
|
|
) : (
|
|
<div className="text-neutral-500 flex items-center space-x-2">
|
|
<div className="w-2 h-2 bg-gray-500 rounded-full"></div>
|
|
<span>{t("offline")}</span>
|
|
</div>
|
|
)}
|
|
</InfoSectionContent>
|
|
</InfoSection>
|
|
<InfoSection>
|
|
<InfoSectionTitle>{t("address")}</InfoSectionTitle>
|
|
<InfoSectionContent>
|
|
{client.subnet.split("/")[0]}
|
|
</InfoSectionContent>
|
|
</InfoSection>
|
|
</InfoSections>
|
|
</AlertDescription>
|
|
</Alert>
|
|
);
|
|
}
|