"use client"; import { Center, Flex, ScrollArea, SimpleGrid, Stack, Text } from "@mantine/core"; import { clientApi } from "@homarr/api/client"; import { useScopedI18n } from "@homarr/translation/client"; import type { WidgetComponentProps } from "../definition"; import { VpnIntegrationCard } from "./vpn-card"; export default function VpnWidget({ options, integrationIds, width, height, displayMode = "compact", }: WidgetComponentProps<"vpn">) { const { data: integrations = [], isPending } = clientApi.widget.vpn.getSummaries.useQuery({ ...options, integrationIds, }); const t = useScopedI18n("widget.vpn"); const tCommon = useScopedI18n("common"); const dense = displayMode === "compact" && (width < 240 || height < 120); if (isPending || integrations.length === 0) { return (
{isPending ? tCommon("action.loading") : t("serviceUnavailable")}
); } const [vpn] = integrations; if (displayMode === "compact" && integrations.length === 1 && vpn) { return ( ); } if (displayMode === "advanced") { return ( = 760 ? 2 : 1} spacing="md"> {integrations.map((result) => ( {!result.error && new Date(result.integration.updatedAt).getTime() > 0 && ( {new Date(result.integration.updatedAt).toLocaleString()} )} ))} ); } return ( {integrations.map((result) => ( ))} ); }