import {Component} from '@angular/core';
import {Store} from '@ngrx/store';
import {StateInterface} from '../../reducers';
import {CommonModule} from '@angular/common';

@Component({
  selector: 'app-loading-notification',
  imports: [CommonModule],
  templateUrl: './loading-notification.html',
  styleUrl: './loading-notification.scss'
})
export class LoadingNotification {
  protected loading: boolean = false;
  protected averageResponseTime: number = 500; // Default value

  constructor(private store: Store<StateInterface>) {
    // Subscribe to the app state to get the loading state
    this.store.select(state => state.app.loading).subscribe(loading => {
      this.loading = loading;
    });

    // Subscribe to the app state to get the average response time
    this.store.select(state => state.app.averageResponseTime).subscribe(time => {
      this.averageResponseTime = time;
    });
  }
}
