organizee-front/src/app/pages/page-account/page-account.component.ts

52 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-01-18 17:12:04 +01:00
import { Component, OnInit } from '@angular/core';
2022-02-16 19:18:24 +01:00
import { MembreService } from 'src/app/services/membre.service';
import { TeamService } from 'src/app/services/team.service';
import { TokenService } from 'src/app/services/token.service';
2022-01-18 17:12:04 +01:00
@Component({
selector: 'app-page-account',
templateUrl: './page-account.component.html',
styleUrls: ['./page-account.component.scss']
})
export class PageAccountComponent implements OnInit {
2022-02-16 19:18:24 +01:00
public listMembres: any[];
currentUser: any;
currentTeam: any;
2022-03-06 18:30:50 +01:00
parent: boolean;
2022-01-18 17:12:04 +01:00
constructor(private membreService: MembreService,
private teamService: TeamService,
2022-03-06 20:49:53 +01:00
private tokenService: TokenService) {
2022-02-16 19:18:24 +01:00
this.listMembres = [];
2022-03-06 18:30:50 +01:00
this.parent = false;
2022-02-16 19:18:24 +01:00
}
2022-01-18 17:12:04 +01:00
ngOnInit(): void {
/** Récuperer la team du membre connecté **/
this.teamService.getTeamById()?.subscribe((team) => {
this.currentTeam = team;
});
/** Récuperer le membre connecté **/
this.membreService.getMembreId(this.tokenService.getCurrentMembreId()).subscribe((user) => {
this.currentUser = user;
});
/** Récuperer la liste des membres de la team **/
this.membreService.getMembresByTeamId()?.subscribe((membres: any[]) => {
2022-02-16 19:18:24 +01:00
this.listMembres = membres;
});
2022-03-06 18:30:50 +01:00
/** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/
/** Il s'agit de cacher les boutons qui permettent de modifier et supprimer les profils (html)**/
const userRole = this.tokenService.getRole();
if(userRole == "ROLE_PARENT"){
2022-03-06 18:30:50 +01:00
this.parent = true;
}
else if(userRole== "ROLE_ENFANT"){
this.parent = false;
2022-03-06 18:30:50 +01:00
}
}
2022-01-18 17:12:04 +01:00
}