Redirect to tabs when user is selected

This commit is contained in:
Huffle 2025-05-15 10:56:04 +02:00
parent 6d6460ac3e
commit ef86deb222
4 changed files with 12 additions and 5 deletions

View File

@ -14,7 +14,7 @@ export class AppComponent {
this.storageService.getCurrentUserId().then((userId) => {
if (userId !== undefined && userId !== null) {
console.log('userId: ', userId);
this.router.navigate(['/tabs'], userId);
this.router.navigate(['/tabs/allowance', userId]);
}
});
})

View File

@ -4,7 +4,7 @@ import { AllowancePage } from './allowance.page';
const routes: Routes = [
{
path: '',
path: ':id',
component: AllowancePage,
}
];

View File

@ -6,14 +6,14 @@
}
.title {
margin-top: 40%;
margin-top: 150px;
color: var(--ion-color-primary);
font-size: 40px;
}
.selection {
gap: 10%;
margin-top: 20%;
margin-top: 100px;
color: var(--ion-color-primary);
}
@ -27,4 +27,5 @@
height: 130px;
border: 1px solid var(--ion-color-primary);
border-radius: 10px;
background-color: var(--ion-color-secondary);
}

View File

@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { User } from 'src/app/models/user';
import { StorageService } from 'src/app/services/storage.service';
import { UserService } from 'src/app/services/user.service';
@ -12,7 +13,11 @@ import { UserService } from 'src/app/services/user.service';
export class UserLoginPage implements OnInit {
public users: Array<User> = [];
constructor(private userService: UserService, private storageService: StorageService) { }
constructor(
private userService: UserService,
private storageService: StorageService,
private router: Router
) { }
ngOnInit() {
this.userService.getUserList().subscribe(users => {
@ -22,5 +27,6 @@ export class UserLoginPage implements OnInit {
selectUser(id: number) {
this.storageService.set('user-id', id);
this.router.navigate(['/tabs/allowance', id]);
}
}