import { useState } from 'react';
import { useGetOne, Title, useNotify } from 'react-admin';
import { Card, CardContent, Typography, Box, Chip, Stack, Divider, Button } from '@mui/material';
import VpnKeyIcon from '@mui/icons-material/VpnKey';
import { apiFetch } from './dataProvider';
const Mono = ({ children }) => (
{children}
);
const DkimButton = ({ domain, onDone }) => {
const [busy, setBusy] = useState(false);
const notify = useNotify();
const gen = () => {
setBusy(true);
apiFetch('/mailserver/dkim', { method: 'POST', body: JSON.stringify({ domain }) })
.then(() => { notify(`DKIM für ${domain} erzeugt`, { type: 'success' }); onDone?.(); })
.catch((e) => notify(e?.body?.error || 'DKIM-Erzeugung fehlgeschlagen', { type: 'warning' }))
.finally(() => setBusy(false));
};
return (
} onClick={gen} disabled={busy} sx={{ mt: 1 }}>
{busy ? 'Erzeuge …' : 'DKIM erzeugen / erneuern'}
);
};
export const StatusPage = () => {
const { data, isLoading, error, refetch } = useGetOne('status', { id: 'status' });
if (isLoading) return Lädt …;
if (error) return Fehler beim Laden des Status.;
return (
Mailserver
{(data.domains || []).map((d) => )}
DNS — Mailhost (einmalig)
{[data.host?.a, data.host?.ptr].filter(Boolean).join('\n')}
{(data.records || []).map((r) => (
{r.domain}
{[r.mx, r.spf, r.dmarc].join('\n')}
DKIM (TXT)
{r.dkim
? {r.dkim}
: Noch kein DKIM-Schlüssel.}
))}
);
};