basic login/logout

This commit is contained in:
eneller
2026-03-07 14:48:19 +01:00
parent 111d1a7b48
commit f5ae9ac9e6
7 changed files with 49 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ import { CommonModule, CurrencyPipe, DatePipe } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { APIService } from '../../services/api';
import Transaction from '@model/transaction';
import { Router } from '@angular/router';
@Component({
selector: 'app-screen-profile',
@@ -15,7 +16,10 @@ export class ScreenProfile implements OnInit{
balance = 200;
transactions!: Transaction[];
constructor(private api: APIService){}
constructor(
private api: APIService,
private router: Router,
){}
ngOnInit(): void {
// FIXME transactions displaying delayed (only on second nav click)
@@ -28,5 +32,15 @@ export class ScreenProfile implements OnInit{
},
})
}
logOut(){
this.api.logout().subscribe({
next: () => {
this.router.navigate(['login'])
},
error: (err) => {
console.error('Error logging out:', err)
}
})
}
}