import Link from "next/link"; import { auth } from "@/auth/config"; import { hasPermission } from "@/auth/permissions"; import type { SystemRole } from "@/auth/roles"; import { getEmailSettings } from "@/db/settings"; import { getUserSecurity } from "@/db/users"; import { getStorageSettings } from "@/db/storage-settings"; import { mediaStorage } from "@/lib/media-storage"; import { CHURCH_TIMEZONE } from "@/lib/tz"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { SettingsForm } from "@/components/app/settings-form"; import { StoragePanel } from "@/components/app/storage-panel"; import { PasswordForm } from "@/components/app/password-form"; export const metadata = { title: "Settings" }; /** * Deployment facts plus the admin-editable email identity. The From address * and admin notification inbox live in the database, so changing them does not * require a deploy or a container restart. */ export default async function SettingsPage() { const session = await auth(); const role = (session?.user as { systemRole?: SystemRole } | undefined)?.systemRole; const userId = (session?.user as { id?: string } | undefined)?.id; const security = userId ? await getUserSecurity(userId) : null; const isAdmin = hasPermission(role, "admin.settings"); const emailSettings = isAdmin ? await getEmailSettings() : null; // Keep the form populated even while the destination is unusable, so an // admin can see and fix what is saved. const storageSettings = isAdmin ? await getStorageSettings() : null; const media = isAdmin ? await mediaStorage() : null; const storageStatus = media ? { ready: media.ok, message: media.ok ? `Event photos and videos are stored in ${media.root}.` : media.message, freeBytes: media.ok ? media.freeBytes : null, mount: media.ok ? media.mount : null, } : null; const emailTransport = emailSettings?.smtpConfigured ? "Gmail (SMTP)" : process.env.POSTMARK_SERVER_TOKEN ? "Postmark" : "Console outbox (dev)"; return (
Church details and how the app is configured.
People, services, reminder rules, and the notification log live in{" "} Admin .
)}