"use client"; import { useActionState } from "react"; import { Button } from "@/components/ui"; import { useI18n } from "@/i18n/i18n-provider"; import { runSmtpTestAction, type SmtpTestState } from "./actions"; export function SmtpTestPanel() { const { t } = useI18n(); const s = t.adminEmailTestPage; const [state, formAction, isPending] = useActionState(runSmtpTestAction, null); return (
{state && "rateLimited" in state ? (

Zu viele Tests. Bitte warte ein paar Minuten.

) : null} {state && "ok" in state && state.ok ? (

{s.success(state.to)}

) : null} {state && "ok" in state && !state.ok && !state.configured ? (

{s.notConfigured}

{s.missingLabel}: {state.missing.join(", ")}

) : null} {state && "ok" in state && !state.ok && state.configured ? (

{s.failureHeading}

{s.causeLabel}

{state.diagnosis.hint}

{s.detailLabel}

{state.diagnosis.detail || "—"}

{s.configLabel}

{state.authMode === "oauth2" ? s.authModeOAuth : s.authModePassword} · SMTP_HOST={state.host} · SMTP_USER={state.user} · SMTP_FROM={state.from}

) : null}
); }