import { Component, inject, OnInit } from '@angular/core';
import { DashboardStatsService } from '@services/dossier-templates/dashboard-stats.service';
import { UserPreferenceService } from '@users/user-preference.service';
import { trackByFactory } from '@iqser/common-ui/lib/utils';
import { User } from '@red/domain';
import { getCurrentUser } from '@iqser/common-ui/lib/users';

@Component({
    templateUrl: './dashboard-screen.component.html',
    styleUrls: ['./dashboard-screen.component.scss'],
})
export class DashboardScreenComponent implements OnInit {
    readonly currentUser = getCurrentUser<User>();
    readonly stats$ = inject(DashboardStatsService).all$;
    readonly trackBy = trackByFactory();

    constructor(private readonly _userPreferenceService: UserPreferenceService) {}

    async ngOnInit(): Promise<void> {
        await this._userPreferenceService.saveLastDossierTemplate(null);
    }
}
