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

@Injectable({ providedIn: 'root' })
export class DashboardGuard implements CanActivate {
    constructor(private readonly _dashboardStatsService: DashboardStatsService) {}

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