Files
frontend/src/app/app.ts
Piet Ostendorp 7ffec411ad Redirect first-time visitors to info page
Updated routing to use MainPage as the default route and added logic in App component to redirect users to the /info page on their first visit using sessionStorage.
2025-10-26 00:40:14 +02:00

24 lines
590 B
TypeScript

import { Component, OnInit, signal } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.html',
standalone: false,
styleUrl: './app.css',
})
export class App implements OnInit{
protected readonly title = signal('infinifront');
constructor(private router: Router) {}
ngOnInit(): void {
const hasVisited = sessionStorage.getItem('hasVisited');
if (!hasVisited) {
sessionStorage.setItem('hasVisited', 'true');
this.router.navigateByUrl('/info', { skipLocationChange: true });
}
}
}