/** Angular Imports */ import { Injectable, inject } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; /** rxjs Imports */ import { Observable, of } from 'rxjs'; /** * Notification service. */ @Injectable({ providedIn: 'root' }) export class NotificationsService { private http = inject(HttpClient); /** * @returns {Observable} Notifications. */ getNotifications(isRead: boolean, limit: number): Observable { const httpParams = new HttpParams().set('isRead', isRead.toString()).set('limit', limit); return this.http.get('/notifications', { params: httpParams }); } /** * @returns {Observable} Notifications. */ updateNotifications(): Observable { return this.http.put('/notifications', {}); } /** * @returns {Observable} Mock Unread Notifications for Testing. */ getMockUnreadNotification(): Observable { const date = new Date(); return of({ totalFilteredRecords: 1, pageItems: [ { id: Math.floor(Math.random() * 100), objectType: 'client', objectId: Math.floor(Math.random() * 10), action: 'clientCreated', actorId: 2, content: 'Client Created', isRead: false, isSystemGenerated: false, createdAt: `${date.toLocaleDateString()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}` } ] }); } }