This commit is contained in:
2026-05-11 15:59:57 +03:30
parent 7b3a27110a
commit 3e48e8fd5c
5 changed files with 57 additions and 31 deletions
+7 -5
View File
@@ -10,11 +10,13 @@ export const appRoutes: Routes = [
{ {
path: '', path: '',
loadComponent: () => import('@/layout/default/app.layout.component').then((m) => m.AppLayout), loadComponent: () => import('@/layout/default/app.layout.component').then((m) => m.AppLayout),
children: [SUPER_ADMIN_ROUTES, CONSUMER_ROUTES, PROVIDER_ROUTES, PARTNER_ROUTES], children: [
}, SUPER_ADMIN_ROUTES,
{ CONSUMER_ROUTES,
...POS_ROUTES, PROVIDER_ROUTES,
path: 'pos', PARTNER_ROUTES,
...POS_ROUTES.children!,
],
}, },
{ {
@@ -25,8 +25,11 @@
<!-- [ngStyle]="{ transform: 'scale(1.' + pullDistance() * 10 + ')' }" --> <!-- [ngStyle]="{ transform: 'scale(1.' + pullDistance() * 10 + ')' }" -->
</div> </div>
} }
{{ isAuth() }}
@if (isAuth()) { @if (isAuth()) {
<router-outlet></router-outlet> @defer (when isAuth()) {
<router-outlet></router-outlet>
}
} @else { } @else {
@defer (when !isAuth()) { @defer (when !isAuth()) {
<pos-pages-layout /> <pos-pages-layout />
@@ -1,6 +1,7 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, computed, signal } from '@angular/core'; import { Component, computed, inject, signal } from '@angular/core';
import { RouterOutlet } from '@angular/router'; import { NavigationEnd, Router, RouterOutlet } from '@angular/router';
import { filter } from 'rxjs';
import { PosSplashComponent } from '../components/splash.component'; import { PosSplashComponent } from '../components/splash.component';
import { PosPagesLayoutComponent } from './pagesLayout/layout.component'; import { PosPagesLayoutComponent } from './pagesLayout/layout.component';
@@ -10,14 +11,23 @@ import { PosPagesLayoutComponent } from './pagesLayout/layout.component';
imports: [PosSplashComponent, PosPagesLayoutComponent, RouterOutlet, CommonModule], imports: [PosSplashComponent, PosPagesLayoutComponent, RouterOutlet, CommonModule],
}) })
export class PosLayoutComponent { export class PosLayoutComponent {
private readonly router = inject(Router);
showSplash = signal(true); showSplash = signal(true);
isAuth = computed(() => window.location.pathname === '/auth'); private readonly currentUrl = signal(this.router.url);
isAuth = computed(() => this.currentUrl() === '/auth');
private touchStartY = 0; private touchStartY = 0;
private pulling = false; private pulling = false;
pullDistance = signal(0); pullDistance = signal(0);
readonly pullThreshold = 80; readonly pullThreshold = 80;
constructor() {
this.router.events
.pipe(filter((event) => event instanceof NavigationEnd))
.subscribe(() => this.currentUrl.set(this.router.url));
}
onSplashCompleted() { onSplashCompleted() {
this.showSplash.set(false); this.showSplash.set(false);
} }
+25 -21
View File
@@ -138,32 +138,36 @@ export class AppLayout {
this.layoutService.topbarCenterSlot$.subscribe((tpl) => (this.topBarCenterAction = tpl)); this.layoutService.topbarCenterSlot$.subscribe((tpl) => (this.topBarCenterAction = tpl));
this.layoutService.topbarEndSlot$.subscribe((tpl) => (this.topBarEndAction = tpl)); this.layoutService.topbarEndSlot$.subscribe((tpl) => (this.topBarEndAction = tpl));
console.log(this.authService.currentAccount());
if (window.location.pathname === '/') { if (window.location.pathname === '/') {
if (!this.authService.currentAccount()) { if (!this.authService.currentAccount()) {
this.router.navigateByUrl('auth'); this.router.navigateByUrl('auth');
} } else {
let redirectUrl = '';
let redirectUrl = ''; switch (this.authService.currentAccount()?.type) {
case 'ADMIN':
switch (this.authService.currentAccount()?.type) { redirectUrl = '/super_admin';
case 'ADMIN': break;
redirectUrl = '/super_admin'; case 'PROVIDER':
break; redirectUrl = '/provider';
case 'PROVIDER': break;
redirectUrl = '/provider'; case 'PARTNER':
break; redirectUrl = '/partner';
case 'PARTNER': break;
redirectUrl = '/partner'; case 'CONSUMER':
break; if (this.authService.currentAccount()?.role === 'OWNER') {
case 'CONSUMER': redirectUrl = '/consumer';
if (this.authService.currentAccount()?.role === 'OWNER') { } else {
redirectUrl = '/consumer'; redirectUrl = config.isPosApplication ? '/' : '/pos';
} else { }
redirectUrl = config.isPosApplication ? '/' : '/pos'; break;
} }
break; if (redirectUrl) {
this.router.navigateByUrl(redirectUrl);
}
} }
this.router.navigateByUrl(redirectUrl);
} }
} }
+8 -1
View File
@@ -10,8 +10,15 @@ export const appRoutes: Routes = [
{ {
path: '', path: '',
loadComponent: () => import('@/layout/default/app.layout.component').then((m) => m.AppLayout), loadComponent: () => import('@/layout/default/app.layout.component').then((m) => m.AppLayout),
children: [SUPER_ADMIN_ROUTES, CONSUMER_ROUTES, PROVIDER_ROUTES, PARTNER_ROUTES, POS_ROUTES], children: [
SUPER_ADMIN_ROUTES,
CONSUMER_ROUTES,
PROVIDER_ROUTES,
PARTNER_ROUTES,
...POS_ROUTES.children!,
],
}, },
{ {
path: 'auth', path: 'auth',
loadComponent: () => import('@/modules/auth/pages/auth.component').then((m) => m.AuthComponent), loadComponent: () => import('@/modules/auth/pages/auth.component').then((m) => m.AuthComponent),