import { Injectable } from '@angular/core' ; import { Resolve , Router , RouterStateSnapshot , ActivatedRouteSnapshot } from '@angular/router' ; import { EmployeesService } from '../../@core/services' ; import { ErrorHandlingService } from '../../@core/services/error-handling.service' ; import { catchError } from 'rxjs/operators' ; import { EMPTY , Observable } from 'rxjs' ; import { IEmployee } from '@gauzy/contracts' ; @ Injectable ( { providedIn : 'root' } ) export class EmployeeResolver implements Resolve < any > { constructor ( private employeesService , private router , private errorHandlingService ) { } resolve ( route , state ) { return this . employeesService . getPublicById ( route . params . employeeId , [ 'user' , 'organization' , 'organizationEmploymentTypes' , 'tags' , 'skills' ] ) . pipe ( catchError ( ( e ) => { this . errorHandlingService . handleError ( e ) ; this . router . navigateByUrl ( '/' ) ; return EMPTY ; } ) ) ; } }