4d5269aced
New Settings → Notifications section with a toggle per category (follow, comment, reply, reaction, rating, mention, leftover-expiring, shared shopping list) — previously it was all-or-nothing (browser permission only). userNotificationPrefs (one row per user, defaults all-on so existing users see no behavior change until they opt out of something). Gated the push send in the three places that dispatch one: lib/notifications.ts (the 6 in-app notification types), the leftover-expiry cron, and shopping-list-notify — in-app notification-center entries and email are unaffected, this only gates the push itself, matching the literal ask. Verified locally: GET/PUT round-trips correctly, disabling a category and confirming the settings page renders all 8 toggles.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { headers } from "next/headers";
|
|
import { auth } from "@/lib/auth/server";
|
|
import { PushSubscribeButton } from "@/components/pwa/push-subscribe-button";
|
|
import { NotificationCategoriesForm } from "@/components/settings/notification-categories-form";
|
|
import { getMessages } from "@/lib/i18n/server";
|
|
|
|
export const metadata: Metadata = {};
|
|
|
|
export default async function NotificationsPage() {
|
|
const session = await auth.api.getSession({ headers: await headers() });
|
|
const m = getMessages((session?.user as { locale?: string })?.locale);
|
|
|
|
return (
|
|
<div className="space-y-8">
|
|
<section className="rounded-xl border p-6 space-y-4">
|
|
<div>
|
|
<h2 className="font-semibold text-lg">{m.settings.pushNotifications.title}</h2>
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
{m.settings.pushNotifications.description}
|
|
</p>
|
|
</div>
|
|
<PushSubscribeButton />
|
|
</section>
|
|
|
|
<section className="rounded-xl border p-6 space-y-4">
|
|
<div>
|
|
<h2 className="font-semibold text-lg">{m.settingsForm.notificationCategories.title}</h2>
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
{m.settingsForm.notificationCategories.description}
|
|
</p>
|
|
</div>
|
|
<NotificationCategoriesForm />
|
|
</section>
|
|
</div>
|
|
);
|
|
}
|