41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import Link from "next/link";
|
|
import Shell from "../components/shell";
|
|
import { getDb } from "@/lib/db";
|
|
import { getViewer } from "@/lib/viewer";
|
|
import { DEFAULT_TAGE_VORHER } from "@/lib/settings";
|
|
import SettingsTabs from "./tabs";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function SettingsPage() {
|
|
const db = getDb();
|
|
const me = await getViewer();
|
|
if (!me) return null;
|
|
const isAdmin = me.role === "admin";
|
|
const isHouseholdAdmin = !isAdmin && me.householdId !== null && me.householdRole === "admin";
|
|
const last = await db.notificationLog.findFirst({ orderBy: { sentAt: "desc" } });
|
|
return (
|
|
<Shell>
|
|
<Link href="/" className="text-sm font-medium text-muted hover:text-ink">
|
|
← Zurück
|
|
</Link>
|
|
<h1 className="mt-2 text-2xl font-semibold tracking-tight">Einstellungen</h1>
|
|
<p className="mt-1 text-sm text-muted">Erinnerungen, Benachrichtigungen, Dienste und Daten.</p>
|
|
<SettingsTabs
|
|
isAdmin={isAdmin}
|
|
isHouseholdAdmin={isHouseholdAdmin}
|
|
ownId={me.id}
|
|
ownEmail={me.email}
|
|
householdId={me.householdId}
|
|
householdName={me.householdName}
|
|
defaultReminderText={`Neue Gutscheine erhalten diese Erinnerungsregeln: ${DEFAULT_TAGE_VORHER.join(", ")} Tage vorher.`}
|
|
lastCronText={
|
|
last
|
|
? `${last.sentAt.toLocaleDateString("de-DE")} · ${last.kanal} an ${last.empfaenger} · ${last.status}${last.fehler ? ` · Fehler: ${last.fehler}` : ""}`
|
|
: null
|
|
}
|
|
/>
|
|
</Shell>
|
|
);
|
|
}
|