Merge branch 'dev' into sana

This commit is contained in:
AlineRinquin 2022-02-17 10:22:14 +01:00 committed by GitHub
commit 60c1753ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 279 additions and 178 deletions

View file

@ -33,10 +33,15 @@ apiUrl: string;
return this.http.get(`${this.apiUrl}/menus/` + id);
}
addMenu(menu: Menu): Observable<any> {
addMenu(menu: Menu): Observable<any> | void {
console.log(menu);
const teamId = this.tokenService.getCurrentTeamId();
if (teamId){
return this.http.post(`${this.apiUrl}/menus/add/${teamId}`, menu);
}else {
this.router.navigate(['accueil']);
}
return this.http.post(`${this.apiUrl}/menus/add`, menu);
}
deleteMenu(id: any): Observable<any> {

View file

@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import jwt_decode from 'jwt-decode';
@Injectable({
providedIn: 'root'
})
@ -42,4 +43,17 @@ return null;
}
}
public getRole(): string | null {
const token = this.getToken();
if(token){
const decodedToken = jwt_decode<any>(token);
const role= decodedToken.auth[0].authority;
return role;
}else{
return null;
}
}
}