import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { DashboardStatsService } from '@services/dossier-templates/dashboard-stats.service';
import { firstValueFrom } from 'rxjs';

// TODO: Remove this and use a CanActivateFn instead
@Injectable({ providedIn: 'root' })
export class DashboardGuard implements CanActivate {
    constructor(private readonly _dashboardStatsService: DashboardStatsService) {}

    async canActivate(): Promise<boolean> {
        await firstValueFrom(this._dashboardStatsService.loadAll());
        return true;
    }
}
