diff --git a/src/app.routes.ts b/src/app.routes.ts
index c32f4f2..35bb13f 100644
--- a/src/app.routes.ts
+++ b/src/app.routes.ts
@@ -10,11 +10,13 @@ export const appRoutes: Routes = [
{
path: '',
loadComponent: () => import('@/layout/default/app.layout.component').then((m) => m.AppLayout),
- children: [SUPER_ADMIN_ROUTES, CONSUMER_ROUTES, PROVIDER_ROUTES, PARTNER_ROUTES],
- },
- {
- ...POS_ROUTES,
- path: 'pos',
+ children: [
+ SUPER_ADMIN_ROUTES,
+ CONSUMER_ROUTES,
+ PROVIDER_ROUTES,
+ PARTNER_ROUTES,
+ ...POS_ROUTES.children!,
+ ],
},
{
diff --git a/src/app/domains/pos/layouts/layout.component.html b/src/app/domains/pos/layouts/layout.component.html
index 909538a..5b172d3 100644
--- a/src/app/domains/pos/layouts/layout.component.html
+++ b/src/app/domains/pos/layouts/layout.component.html
@@ -25,8 +25,11 @@
}
+ {{ isAuth() }}
@if (isAuth()) {
-
+ @defer (when isAuth()) {
+
+ }
} @else {
@defer (when !isAuth()) {
diff --git a/src/app/domains/pos/layouts/layout.component.ts b/src/app/domains/pos/layouts/layout.component.ts
index 5b48242..55508ae 100644
--- a/src/app/domains/pos/layouts/layout.component.ts
+++ b/src/app/domains/pos/layouts/layout.component.ts
@@ -1,6 +1,7 @@
import { CommonModule } from '@angular/common';
-import { Component, computed, signal } from '@angular/core';
-import { RouterOutlet } from '@angular/router';
+import { Component, computed, inject, signal } from '@angular/core';
+import { NavigationEnd, Router, RouterOutlet } from '@angular/router';
+import { filter } from 'rxjs';
import { PosSplashComponent } from '../components/splash.component';
import { PosPagesLayoutComponent } from './pagesLayout/layout.component';
@@ -10,14 +11,23 @@ import { PosPagesLayoutComponent } from './pagesLayout/layout.component';
imports: [PosSplashComponent, PosPagesLayoutComponent, RouterOutlet, CommonModule],
})
export class PosLayoutComponent {
+ private readonly router = inject(Router);
+
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 pulling = false;
pullDistance = signal(0);
readonly pullThreshold = 80;
+ constructor() {
+ this.router.events
+ .pipe(filter((event) => event instanceof NavigationEnd))
+ .subscribe(() => this.currentUrl.set(this.router.url));
+ }
+
onSplashCompleted() {
this.showSplash.set(false);
}
diff --git a/src/app/layout/default/app.layout.component.ts b/src/app/layout/default/app.layout.component.ts
index 5f56b42..28d4967 100644
--- a/src/app/layout/default/app.layout.component.ts
+++ b/src/app/layout/default/app.layout.component.ts
@@ -138,32 +138,36 @@ export class AppLayout {
this.layoutService.topbarCenterSlot$.subscribe((tpl) => (this.topBarCenterAction = tpl));
this.layoutService.topbarEndSlot$.subscribe((tpl) => (this.topBarEndAction = tpl));
+ console.log(this.authService.currentAccount());
+
if (window.location.pathname === '/') {
if (!this.authService.currentAccount()) {
this.router.navigateByUrl('auth');
- }
+ } else {
+ let redirectUrl = '';
- let redirectUrl = '';
-
- switch (this.authService.currentAccount()?.type) {
- case 'ADMIN':
- redirectUrl = '/super_admin';
- break;
- case 'PROVIDER':
- redirectUrl = '/provider';
- break;
- case 'PARTNER':
- redirectUrl = '/partner';
- break;
- case 'CONSUMER':
- if (this.authService.currentAccount()?.role === 'OWNER') {
- redirectUrl = '/consumer';
- } else {
- redirectUrl = config.isPosApplication ? '/' : '/pos';
- }
- break;
+ switch (this.authService.currentAccount()?.type) {
+ case 'ADMIN':
+ redirectUrl = '/super_admin';
+ break;
+ case 'PROVIDER':
+ redirectUrl = '/provider';
+ break;
+ case 'PARTNER':
+ redirectUrl = '/partner';
+ break;
+ case 'CONSUMER':
+ if (this.authService.currentAccount()?.role === 'OWNER') {
+ redirectUrl = '/consumer';
+ } else {
+ redirectUrl = config.isPosApplication ? '/' : '/pos';
+ }
+ break;
+ }
+ if (redirectUrl) {
+ this.router.navigateByUrl(redirectUrl);
+ }
}
- this.router.navigateByUrl(redirectUrl);
}
}
diff --git a/src/tenants/default/app.routes.ts b/src/tenants/default/app.routes.ts
index 6f74d57..35bb13f 100644
--- a/src/tenants/default/app.routes.ts
+++ b/src/tenants/default/app.routes.ts
@@ -10,8 +10,15 @@ export const appRoutes: Routes = [
{
path: '',
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',
loadComponent: () => import('@/modules/auth/pages/auth.component').then((m) => m.AuthComponent),