1 import { Component, ViewChild } from '@angular/core'
2 import { UserNotificationsComponent } from '@app/shared/shared-main'
4 type NotificationSortType = 'createdAt' | 'read'
7 templateUrl: './my-account-notifications.component.html',
8 styleUrls: [ './my-account-notifications.component.scss' ]
10 export class MyAccountNotificationsComponent {
11 @ViewChild('userNotification', { static: true }) userNotification: UserNotificationsComponent
13 _notificationSortType: NotificationSortType = 'createdAt'
15 get notificationSortType () {
16 return !this.hasUnreadNotifications()
18 : this._notificationSortType
21 set notificationSortType (type: NotificationSortType) {
22 this._notificationSortType = type
26 this.userNotification.markAllAsRead()
29 hasUnreadNotifications () {
30 return this.userNotification.notifications.filter(n => n.read === false).length !== 0
33 onChangeSortColumn () {
34 this.userNotification.changeSortColumn(this.notificationSortType)