push to maple-street
This commit is contained in:
+167
-10
@@ -1,16 +1,173 @@
|
||||
import { StateMessage } from "@/components/app/state-message";
|
||||
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 {
|
||||
checkArchiveDestination,
|
||||
getStorageSettings,
|
||||
} from "@/db/storage-settings";
|
||||
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" };
|
||||
|
||||
export default function SettingsPage() {
|
||||
/**
|
||||
* 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;
|
||||
const storageSettings = isAdmin ? await getStorageSettings() : null;
|
||||
const storageStatus = storageSettings
|
||||
? await checkArchiveDestination(storageSettings)
|
||||
: null;
|
||||
const emailTransport = emailSettings?.smtpConfigured
|
||||
? "Gmail (SMTP)"
|
||||
: process.env.POSTMARK_SERVER_TOKEN
|
||||
? "Postmark"
|
||||
: "Console outbox (dev)";
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1 className="text-lg font-semibold tracking-tight">Settings</h1>
|
||||
<p className="text-sm text-muted-foreground">Church details, timezone, and scheduling rules.</p>
|
||||
<StateMessage
|
||||
title="No settings to show"
|
||||
description="Church and scheduling settings appear here. Branding and admin settings are restricted to admins."
|
||||
/>
|
||||
</>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold tracking-tight">Settings</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Church details and how the app is configured.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{security && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">My account</CardTitle>
|
||||
<CardDescription>
|
||||
Your username and password for signing in. Changing either does
|
||||
not sign you out of this session.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<Link
|
||||
href="/profile"
|
||||
className="inline-flex text-sm font-medium text-primary underline"
|
||||
>
|
||||
Edit profile, notifications, skill comfort and calendar feed
|
||||
</Link>
|
||||
<PasswordForm
|
||||
initialUsername={security.username}
|
||||
hasPassword={Boolean(security.passwordHash)}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">Church</CardTitle>
|
||||
<CardDescription>
|
||||
Values that drive scheduling and message delivery.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<dl className="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
||||
Timezone
|
||||
</dt>
|
||||
<dd className="mt-1 text-sm text-foreground">{CHURCH_TIMEZONE}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
||||
Week starts
|
||||
</dt>
|
||||
<dd className="mt-1 text-sm text-foreground">Sunday</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
||||
Email delivery
|
||||
</dt>
|
||||
<dd className="mt-1 text-sm text-foreground">{emailTransport}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
||||
Signed in as
|
||||
</dt>
|
||||
<dd className="mt-1 text-sm text-foreground">
|
||||
{session?.user?.email ?? "—"}
|
||||
{security && (
|
||||
<span className="block text-xs text-muted-foreground">
|
||||
Username: {security.username}
|
||||
</span>
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{isAdmin && emailSettings && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">Email & notifications</CardTitle>
|
||||
<CardDescription>
|
||||
Sender identity for assignment mail and where admin test messages
|
||||
are delivered.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<SettingsForm
|
||||
emailFrom={emailSettings.emailFrom}
|
||||
notificationEmail={emailSettings.notificationEmail}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{isAdmin && storageSettings && storageStatus && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">Media archive (NFS)</CardTitle>
|
||||
<CardDescription>
|
||||
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.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<StoragePanel
|
||||
initial={storageSettings}
|
||||
initialStatus={storageStatus}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{isAdmin && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
People, services, reminder rules, and the notification log live in{" "}
|
||||
<Link href="/admin" className="font-medium text-primary underline">
|
||||
Admin
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user