basic login/logout
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user