feat(notifications): add per-tenant notification preferences

This commit is contained in:
2026-10-03 14:50:38 +02:00
parent efa6ea90a2
commit 4c67ddd908
12 changed files with 322 additions and 22 deletions

View File

@@ -1301,3 +1301,17 @@ export async function uploadPlantFile(
return parsed as ProjectFile;
}
export type NotificationPreferenceEvent = {
eventKey: string;
displayName: string;
description: string | null;
channels: Partial<Record<'email' | 'push', boolean>>;
};
export async function fetchNotificationPreferences(token: string) {
return apiRequest<{ tenantId: number; events: NotificationPreferenceEvent[] }>('/api/notifications/preferences', { token });
}
export async function saveNotificationPreferences(token: string, events: NotificationPreferenceEvent[]) {
return apiRequest('/api/notifications/preferences', { token, method: 'PUT', body: events.flatMap(event =>
Object.entries(event.channels).map(([channel, enabled]) => ({ eventType: event.eventKey, channel, enabled }))) });
}