// VA-P23 interim-UI (AD-28) — mailbox connect settings screen composed from // ~/ui: PageShell header, provider connect actions, mailbox cards with status // badge, initial-sync progress and Klartext errors. Presentational; the route // owns loader/action, mutations POST via plain Forms (csrf prop, same pattern // as CalendarConnectionsPage). Final Subframe optics = tracked design-nachzug. import { Form } from "react-router"; import { useTranslation } from "react-i18next"; import { FeatherMail, FeatherPlus } from "@subframe/core"; import type { EmailMailboxListVM, EmailMailboxRow, EmailMailboxStatus } 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 { useLocaleFormatters } from "~/locale/format"; import { PAGE_HEADER_ICON_CLASS, PageBackLink, PageBody, PageHeader, PageIntro, PageShell } from "../shared/PageShell"; export type EmailMailboxSettingsPageProps = { vm: EmailMailboxListVM; csrf: string | null; flash: "connected" | "error" | 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; }; function statusBadgeTone(status: EmailMailboxStatus): "subtle-positive" | "subtle-negative" | "subtle-neutral" { if (status === "active") return "subtle-positive"; if (status === "error" || status === "revoked") return "subtle-negative"; return "subtle-neutral"; } function MailboxCard({ row, csrf }: { row: EmailMailboxRow; csrf: string | null }) { const { t } = useTranslation(); const formatters = useLocaleFormatters(); return (
{row.emailAddress} {t(row.providerKey)}
{row.lastSyncAt ? ( {t("emailInbox.settings.lastSync")}: {formatters.dateTime(row.lastSyncAt)} ) : null}
{t(row.statusKey)} {row.isOwn ? (
{csrf ? : null}
) : null}
{row.initialSync.status !== "completed" ? ( {t(row.initialSync.statusKey)} {row.initialSync.progressPercent !== null && ` — ${row.initialSync.progressPercent}%`} {row.initialSync.fetchedCount !== null && ` (${t("emailInbox.settings.initialSync.fetched", { count: row.initialSync.fetchedCount })})`} ) : null} {row.lastErrorText ? ( {row.lastErrorText.startsWith("emailInbox.") ? t(row.lastErrorText) : row.lastErrorText} ) : null}
); } export function EmailMailboxSettingsPage({ vm, csrf, flash, backHref, embedded = false }: EmailMailboxSettingsPageProps) { const { t } = useTranslation(); if (vm.status !== "ready" || !vm.data) { return ; } const { rows, canConnect, configuredProviders, emptyHeadlineKey, emptyBodyKey, notConfiguredKey } = vm.data; const anyConfigured = configuredProviders.gmail || configuredProviders.microsoft; // AK-SET-01: hoisted so the connect buttons survive in both the standalone // header and the hub's intro row. const connectActions = canConnect && anyConfigured ? ( <> {configuredProviders.gmail ? (
{csrf ? : null}
) : null} {configuredProviders.microsoft ? (
{csrf ? : null}
) : null} ) : null ; return ( {embedded ? null : ( } title={t("emailInbox.settings.title")} subtitle={t("emailInbox.settings.subtitle")} actions={connectActions} /> )} {embedded ? (
{t("emailInbox.settings.subtitle")} {connectActions ?
{connectActions}
: null}
) : ( )} {flash === "connected" ? (
) : null} {flash === "error" ? (
) : null} {!anyConfigured ? (
) : null} {rows.length === 0 ? (
) : (
{rows.map((row) => ( ))}
)}
); }