refactor user accounts structure
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { BreadcrumbService } from '@/core/services';
|
||||
import { AuthService, BreadcrumbService } from '@/core/services';
|
||||
import { BreadcrumbComponent } from '@/shared/components';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
TemplateRef,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { NavigationEnd, Router, RouterModule } from '@angular/router';
|
||||
import { ActivatedRoute, NavigationEnd, Router, RouterModule } from '@angular/router';
|
||||
import { ProgressSpinner } from 'primeng/progressspinner';
|
||||
import { filter, Subscription } from 'rxjs';
|
||||
import { LayoutService } from '../service/layout.service';
|
||||
@@ -46,6 +46,8 @@ export class AppLayout {
|
||||
@ContentChild('content', { static: true }) content?: TemplateRef<any> | null;
|
||||
|
||||
private breadcrumbService = inject(BreadcrumbService);
|
||||
private authService = inject(AuthService);
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
constructor(
|
||||
public layoutService: LayoutService,
|
||||
@@ -141,6 +143,28 @@ export class AppLayout {
|
||||
return this.layoutService.menuItems().length > 0;
|
||||
});
|
||||
|
||||
ngOnInit() {
|
||||
if (window.location.pathname === '/') {
|
||||
if (!this.authService.currentAccount()) {
|
||||
this.router.navigateByUrl('auth');
|
||||
}
|
||||
switch (this.authService.currentAccount()?.type) {
|
||||
case 'ADMIN':
|
||||
this.router.navigateByUrl('super_admin');
|
||||
break;
|
||||
case 'CONSUMER':
|
||||
this.router.navigateByUrl('consumer');
|
||||
break;
|
||||
case 'PARTNER':
|
||||
this.router.navigateByUrl('partner');
|
||||
break;
|
||||
case 'PROVIDER':
|
||||
this.router.navigateByUrl('provider');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.overlayMenuOpenSubscription) {
|
||||
this.overlayMenuOpenSubscription.unsubscribe();
|
||||
|
||||
Reference in New Issue
Block a user