Files
doneit-web/src/app/services/first-enter.service.ts
T
Peter Maquiran 23cf0fc4cb remove alert
2024-07-15 15:11:29 +01:00

51 lines
1.7 KiB
TypeScript

import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { AlertController, Platform } from '@ionic/angular';
import { PermissionService } from '../services/permission.service';
import { SessionStore } from '../store/session.service';
@Injectable({
providedIn: 'root'
})
export class FirstEnterService {
constructor(private router:Router,
public p: PermissionService,
private alertController: AlertController) { }
enter( ) {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user?.OwnerCalendars?.length == 0){
this.router.navigate(['/home/agenda']);
}
else{
this.router.navigate(['/home/events']);
}
}
else if((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)){
this.router.navigate(['/home/chat']);
}
else if(this.p.userPermission(this.p.permissionList.Actions.access)) {
this.router.navigate(['/home/publications']);
} else {
this.alertController.create({
cssClass: 'my-custom-class',
header: 'Utilizador sem acesso a aplicação',
buttons: [{
text: 'Ok',
handler: () => {
}
}]
}).then( async (alertPopup) => {
await alertPopup.present();
})
}
}
}