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 (

Settings

Church details and how the app is configured.

{security && ( My account Your username and password for signing in. Changing either does not sign you out of this session. Edit profile, notifications, skill comfort and calendar feed )} Church Values that drive scheduling and message delivery.
Timezone
{CHURCH_TIMEZONE}
Week starts
Sunday
Email delivery
{emailTransport}
Signed in as
{session?.user?.email ?? "—"} {security && ( Username: {security.username} )}
{isAdmin && emailSettings && ( Email & notifications Sender identity for assignment mail and where admin test messages are delivered. )} {isAdmin && storageSettings && storageStatus && ( Media storage (NFS / local path) Mount an NFS export into this container. Finished event photos are archived here, and every uploaded video keeps its camera original on this mount. Photo archives include originals, saved edits, and a manifest. )} {isAdmin && (

People, services, reminder rules, and the notification log live in{" "} Admin .

)}
); }