mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
51 lines
1.7 KiB
TypeScript
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();
|
|
})
|
|
|
|
}
|
|
}
|
|
}
|