import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { AppBreadcrumbService } from 'src/app/app.breadcrumb.service';
import { Candidate } from 'src/app/shared/models/candidate';
import { CandidateService } from 'src/app/shared/services/candidate.service';

@Component({
  selector: 'app-candidat-detail',
  templateUrl: './candidat-detail.component.html',
  styleUrls: ['./candidat-detail.component.scss']
})
export class CandidatDetailComponent implements OnInit {

  private _candidat: Observable<Candidate> = new Observable<Candidate>() ;
  paramId: string;
  constructor(private breadcrumbService: AppBreadcrumbService,private http: HttpClient, private candidateService: CandidateService, private route: ActivatedRoute) {
    this.breadcrumbService.setItems([
      { label: 'Candidats' },
      { label: 'Detail', routerLink: ['/candidat/:candidatId/candidat-list'] }
    ]);
  }

  ngOnInit(): void {
  //  this.route.data.subscribe((data: { candidat: Observable<Candidate> }) => this._candidat = data.candidat);
    this.route.paramMap.subscribe(params => {
      if (params.get('candidatId')) {
        this.paramId = params.get('candidatId');
      }
    });
    this._candidat = this.candidateService.candidatGetById(this.paramId);
  }

}
