From 0a74269d56cc46803fd0f1c0234f4a1237ecd225 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 7 Nov 2021 14:12:16 +0200 Subject: [PATCH] updated request --- .../notifications-screen.component.html | 4 +-- .../notifications-screen.component.ts | 26 ++++++++----------- .../notifications-translations.ts | 3 +++ .../notification-preferences.service.ts | 24 +++++++++++++---- apps/red-ui/src/assets/i18n/en.json | 3 +++ libs/common-ui | 2 +- libs/red-domain/src/index.ts | 1 + .../lib/notifications-preferences/index.ts | 1 + 8 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 libs/red-domain/src/lib/notifications-preferences/index.ts diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html index 1659a116f..059169d07 100644 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html @@ -11,7 +11,7 @@
-
+
@@ -35,7 +35,7 @@
-
+
{ - return super.get(); + getNotificationPreferences(): Observable { + return super.get().pipe( + map(notificationPreferences => (Array.isArray(notificationPreferences) ? notificationPreferences[0] : notificationPreferences)), + catchError(() => of(this._defaultPreferences)), + ); } updateNotificationPreferences(notificationPreferences: INotificationPreferences): Observable { return super._post(notificationPreferences); } + + private get _defaultPreferences(): INotificationPreferences { + return { + emailNotificationType: 'INSTANT', + emailNotifications: [], + emailNotificationsEnabled: false, + inAppNotifications: [], + inAppNotificationsEnabled: true, + }; + } } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 8036f1649..76a9badda 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1287,6 +1287,9 @@ "email-notifications": "Email Notifications", "in-app-notifications": "In-App Notifications" }, + "error": { + "generic": "Something went wrong... Preferences update failed!" + }, "groups": { "approver": "Dossiers you are approver on", "own": "Dossiers you own", diff --git a/libs/common-ui b/libs/common-ui index 1df1b1ab8..712178ea3 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 1df1b1ab899e21093eb07c444acf90def933cb02 +Subproject commit 712178ea34c998098cd2c079a0be1dd863dd266e diff --git a/libs/red-domain/src/index.ts b/libs/red-domain/src/index.ts index 5365dabd6..3cd713b40 100644 --- a/libs/red-domain/src/index.ts +++ b/libs/red-domain/src/index.ts @@ -6,6 +6,7 @@ export * from './lib/users'; export * from './lib/pages'; export * from './lib/audit'; export * from './lib/notifications'; +export * from './lib/notifications-preferences'; export * from './lib/dossier-templates'; export * from './lib/dictionaries'; export * from './lib/redaction-log'; diff --git a/libs/red-domain/src/lib/notifications-preferences/index.ts b/libs/red-domain/src/lib/notifications-preferences/index.ts new file mode 100644 index 000000000..8a3478f79 --- /dev/null +++ b/libs/red-domain/src/lib/notifications-preferences/index.ts @@ -0,0 +1 @@ +export * from './notification-preferences';