diff --git a/src/app/home/home-commercial/home-commercial.component.html b/src/app/home/home-commercial/home-commercial.component.html index f0700da..4d6599e 100644 --- a/src/app/home/home-commercial/home-commercial.component.html +++ b/src/app/home/home-commercial/home-commercial.component.html @@ -1 +1,8 @@ -

Page Commercial

+ +

Vos prochains EP

+ +
+ + +

Vous n'avez actuellement aucun EP en cours

+
\ No newline at end of file diff --git a/src/app/home/home-commercial/home-commercial.component.ts b/src/app/home/home-commercial/home-commercial.component.ts index 9e7c058..f1bb52e 100644 --- a/src/app/home/home-commercial/home-commercial.component.ts +++ b/src/app/home/home-commercial/home-commercial.component.ts @@ -1,4 +1,8 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { CollaborateurDTO, EpService } from '@shared/api-swagger'; +import { cles, epTypeRecherche } from '@shared/utils/cles'; +import { Subscription } from 'rxjs'; /** @@ -12,9 +16,49 @@ import { Component, OnInit } from '@angular/core'; templateUrl : 'home-commercial.component.html' }) export class HomeCommercialComponent implements OnInit { - constructor() { + + collaborateurConnecte: CollaborateurDTO; + + countEPReferent: Subscription; + + estReferentEPEnCours: boolean = false; + + displayedColumns : string[] = ["agence", "collaborateur", "datearrivee", "typeep", "statutep", "dateentretien", "consultation" ]; + + epTypeRecherche : any = epTypeRecherche; + + constructor(private epService: EpService, private router: Router) { } ngOnInit() { + this.setCollaborateurConnecte(); + } + + setCollaborateurConnecte() { + if(sessionStorage.getItem(cles.sessionKeyConnectee) == undefined) { + setTimeout( () => this.setCollaborateurConnecte(), 1000); + } + else { + this.collaborateurConnecte = JSON.parse(sessionStorage.getItem(cles.sessionKeyConnectee)); + this.checkEPReferent(); + } + } + + checkEPReferent() { + this.countEPReferent = this.epService.getEPEnCoursReferentCount(this.collaborateurConnecte.id, true, 1, 15, "", "", true, undefined, undefined).subscribe( + count => this.estReferentEPEnCours = count > 0, + err => console.log(err) + ); + } + + + ouvrirEP(event) { + if(event.type == "ep") + this.router.navigate(["/ep", event.ep.id]); + } + + ngDestroy() { + if(this.countEPReferent != undefined) + this.countEPReferent.unsubscribe(); } }