// src/app/services/overlay.service.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

@Injectable({
  providedIn: 'root',
})
export class OverlayService {
  private loadingSubject = new BehaviorSubject<boolean>(false);
  loading$ = this.loadingSubject.asObservable();

  private successSubject = new BehaviorSubject<boolean>(false);
  success$ = this.successSubject.asObservable();

  showLoading() {
    this.loadingSubject.next(true);
  }

  hideLoading() {
    this.loadingSubject.next(false);
  }

  showSuccess() {
    this.successSubject.next(true);
    setTimeout(() => {
      this.successSubject.next(false);
    }, 3000); // Erfolgsmeldung nach 3 Sekunden ausblenden
  }
}
