// R-P5 Interim-UI (AD-28) — reusable Connection-Card (D-P5: app card with status // traffic light, Klartext health hint, last sync time and the lifecycle buttons // Verbinden/Re-Sync/Reconnect/Trennen). All later app connections (P14/P15/P16/ // P20) render through this card. Pure presentational; callbacks injected. import { useTranslation } from "react-i18next"; import { Link } from "react-router"; import type { ConnectionRow } from "@hivegrid/view-models"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { LinkButton } from "~/ui/components/LinkButton"; import { connectionStatusBadge } from "./integrationsBadges"; import { APP_TIME_ZONE } from "~/locale/format"; export type ConnectionCardProps = { row: ConnectionRow; canDisconnect: boolean; canManualSync: boolean; canReconnect: boolean; submitting: boolean; onManualSync: (connectionId: string) => void; onReconnect: (row: ConnectionRow) => void; onDisconnect: (row: ConnectionRow) => void; }; export function ConnectionCard({ row, canDisconnect, canManualSync, canReconnect, submitting, onManualSync, onReconnect, onDisconnect }: ConnectionCardProps) { const { t, i18n } = useTranslation(); const dateFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium", timeStyle: "short" }); const unhealthy = row.status === "degraded" || row.status === "broken"; const revoked = row.status === "revoked"; return (
{row.label} {row.healthMessageKey ? ( {t(row.healthMessageKey)} ) : null}
{t(row.statusKey)}
{t("integrations.connections.column.lastCheck")}: {row.lastHealthCheckIso ? dateFormatter.format(new Date(row.lastHealthCheckIso)) : "—"}
{row.syncsHref ? ( {t("integrations.connections.actions.history")} ) : null}
{canManualSync && !revoked ? ( ) : null} {canReconnect && (unhealthy || revoked) ? ( ) : null} {canDisconnect && !revoked ? ( ) : null}
); }