import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; import { AdminClientService } from '@features/platform-admin/clients/admin-client.service'; import { HistoricalImportService } from '../historical-import.service'; @Injectable({ providedIn: 'root' }) export class AdminBatchResolver implements Resolve { constructor ( private adminClientService: AdminClientService, private historicalImportService: HistoricalImportService ) { } async resolve (next: ActivatedRouteSnapshot) { const batchId = +next.params.id; const batch = await this.historicalImportService.setCurrentBatch(batchId); if (batch) { this.adminClientService.setActiveClient(batch.clientId); await Promise.all([ this.adminClientService.loadProgramsForClientId(batch.clientId), this.adminClientService.fetchClientExtras( batch.clientId ) ]); } } }