added model
This commit is contained in:
parent
5f03843e2c
commit
dd0248e7f5
@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { notificationsTranslations } from '../../translations/notifications-translations';
|
||||
import { NotificationPreferencesService } from '../../../../services/notification-preferences.service';
|
||||
import { LoadingService } from '../../../../../../../../libs/common-ui/src';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-notifications-screen',
|
||||
@ -23,6 +24,7 @@ export class NotificationsScreenComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private readonly _formBuilder: FormBuilder,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _notificationPreferencesService: NotificationPreferencesService,
|
||||
) {}
|
||||
|
||||
@ -60,11 +62,15 @@ export class NotificationsScreenComponent implements OnInit {
|
||||
async save() {
|
||||
console.log('formGroup: ', this.formGroup.value);
|
||||
return;
|
||||
this._loadingService.start();
|
||||
await this._notificationPreferencesService.updateNotificationPreferences(this.formGroup.value).toPromise();
|
||||
this._loadingService.stop();
|
||||
}
|
||||
|
||||
private async _initializeForm() {
|
||||
this._loadingService.start();
|
||||
// const notificationPreferences = await this._notificationPreferencesService.getNotificationPreferences().toPromise();
|
||||
this._loadingService.stop();
|
||||
|
||||
const notificationPreferences = {
|
||||
emailNotificationType: 'DAILY',
|
||||
|
||||
@ -2,20 +2,21 @@ import { Injectable, Injector } from '@angular/core';
|
||||
import { GenericService } from '../../../../../libs/common-ui/src';
|
||||
import { Observable } from 'rxjs';
|
||||
import { UserService } from './user.service';
|
||||
import { INotificationPreferences } from '../../../../../libs/red-domain/src/lib/notifications-preferences/notification-preferences';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class NotificationPreferencesService extends GenericService<any> {
|
||||
export class NotificationPreferencesService extends GenericService<INotificationPreferences> {
|
||||
constructor(protected readonly _injector: Injector, private readonly _userService: UserService) {
|
||||
super(_injector, 'notification-preferences');
|
||||
}
|
||||
|
||||
getNotificationPreferences(): Observable<any> {
|
||||
getNotificationPreferences(): Observable<INotificationPreferences[]> {
|
||||
return super.get();
|
||||
}
|
||||
|
||||
updateNotificationPreferences(body: any): Observable<any> {
|
||||
return super._post(body);
|
||||
updateNotificationPreferences(notificationPreferences: INotificationPreferences): Observable<void> {
|
||||
return super._post(notificationPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
export interface INotificationPreferences {
|
||||
emailNotificationType: 'INSTANT' | 'DAILY' | 'WEEKLY';
|
||||
emailNotifications: string[];
|
||||
emailNotificationsEnabled: boolean;
|
||||
inAppNotifications: string[];
|
||||
inAppNotificationsEnabled: boolean;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user