import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AgentService } from '../service/agent.service';
import { Observable } from 'rxjs';

@Injectable({ providedIn: 'root' })
export class AgentDataForWizardResolver implements Resolve<any> {

  constructor(private service: AgentService) {}

  resolve(
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot
  ): Observable<any>|Promise<any>|any {

    const code = route.paramMap.get('code');

    return this.service.getDataForWizard(parseInt(code, 10));
  }
}
