feat(notifications): add per-tenant notification preferences
This commit is contained in:
@@ -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 }))) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user