import { Form, Link } from "react-router"; import { useTranslation } from "react-i18next"; import { FeatherCalendarClock, FeatherPlus } from "@subframe/core"; import type { CalendarConnectionListVM } from "@hivegrid/view-models"; import { Alert } from "~/ui/components/Alert"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { EmptyState } from "~/ui/components/EmptyState"; import { Table } from "~/ui/components/Table"; import { useLocaleFormatters } from "~/locale/format"; import { PageBackLink, PageIntro } from "../shared/PageShell"; import { PageHeader, statusBadgeTone } from "../automation/automationUi"; /** * AK-P16a · interim calendar-connections settings screen (AD-28, archetype A6). * Renders the server-built CalendarConnectionListVM; the Google connect action * stays a plain POST (`intent=connect`) owned by the route. Final Subframe * optics follow David's D-P16 delta (design-nachzug). */ export interface CalendarConnectionsPageProps { vm: CalendarConnectionListVM; csrf: string | null; /** Path back to the integrations catalog (settings/integrations). */ backHref: string; /** Inside the Erweiterungen hub (AK-SET-01) the hub owns the header. */ embedded?: boolean; } export function CalendarConnectionsPage({ vm, csrf, backHref, embedded = false }: CalendarConnectionsPageProps): React.JSX.Element { const { t } = useTranslation(); const formatters = useLocaleFormatters(); if (vm.status !== "ready" || !vm.data) { return
; } const { rows, canConnect, isConfigured, emptyHeadlineKey, emptyBodyKey, notConfiguredKey } = vm.data; const errored = rows.filter((row) => row.status === "error"); // AK-SET-01: hoisted so the connect button survives in both the standalone // header and the hub's intro row. const connectAction = canConnect && isConfigured ? (
{csrf ? : null}
) : undefined; return (
{embedded ? null : ( } title={t("calendar.connections.title")} subtitle={t("calendar.connections.subtitle")} actions={connectAction} /> )}
{embedded ? (
{t("calendar.connections.subtitle")} {connectAction ?
{connectAction}
: null}
) : ( )} {!isConfigured ? (
) : null} {/* Re-connect banner (hierarchy §8): at least one broken connection. */} {errored.length > 0 ? ( ) : null} {rows.length === 0 ? (
) : (
{t("calendar.connections.table.account")}{t("calendar.connections.table.direction")}{t("calendar.connections.table.lastSync")}{t("calendar.connections.table.status")} } > {rows.map((row) => ( {row.externalAccountEmail} {t(row.syncDirectionKey)} {row.lastSyncAt ? formatters.dateTime(row.lastSyncAt) : t("calendar.detail.neverSynced")} {t(row.statusKey)} ))}
)}
); }