Staff / Owner

Merged staff and owner settings
This commit is contained in:
Stefan Lazic committed 2026-08-05 16:35:52 +01:00
1 parent cf3a28f3cd
commit 3300045d9e
23 files changed
+693 -236

No files matched your search

+10 -3
View File
@@ -1,5 +1,6 @@
"use server";
import { auth } from "@/auth";
import { NotificationType } from "@/generated/prisma/enums";
import { prisma } from "@/lib/db/prisma";
import { getActingStaff } from "@/lib/staff/get-acting-staff";
@@ -36,15 +37,21 @@ export async function updateProfileAction(input: {
return result.success ? { success: true } : { success: false, error: "Couldn't save your profile." };
}
/**
* Keyed purely by userId, not a StaffProfile — a Super Administrator (who
* has no StaffProfile, see isSuperAdmin) still has their own notification
* preferences, so this checks session auth directly rather than requiring
* getActingStaff() the way the staff-specific actions above do.
*/
export async function saveNotificationPreferencesAction(
cells: PreferenceCellState[],
): Promise<ProfileActionResult> {
const staff = await getActingStaff();
if (!staff) return { success: false, error: "You must be signed in as staff." };
const session = await auth();
if (!session?.user?.id) return { success: false, error: "You must be signed in." };
for (const cell of cells) {
await setNotificationPreference(prisma, {
userId: staff.userId,
userId: session.user.id,
type: NotificationType.STAFF_APPOINTMENT_REMINDER,
channel: cell.channel,
isEnabled: cell.isEnabled,