import { Notification } from '../models/Notification';

export class NotificationsService {
  private notifications: Notification[] = [];

  public createNotification(notification: Notification): void {
    this.notifications.push(notification);
  }

  public getNotifications(): Notification[] {
    return this.notifications;
  }

  public deleteNotification(notificationId: string): void {
    this.notifications = this.notifications.filter(n => n.id !== notificationId);
  }

  public markAsRead(notificationId: string): void {
    const notification = this.notifications.find(n => n.id === notificationId);
    if (notification) {
      notification.isRead = true;
    }
  }

  public async sendEmail(_email: string, _subject: string, _message: string): Promise<void> {
    // Email sending logic here
  }

  public async createInAppAlert(userId: string, alertMessage: string): Promise<void> {
    const alert: Notification = {
      id: Math.random().toString(36).substring(2, 11),
      userId,
      message: alertMessage,
      isRead: false,
      createdAt: new Date(),
    };
    this.notifications.push(alert);
  }

  public async sendPushNotification(_userId: string, _notificationMessage: string): Promise<void> {
    // Push notification logic here
  }
}

export default NotificationsService;
