TG-2 TG-9 - Push base Angular app

This commit is contained in:
2024-11-03 11:16:14 +01:00
parent cd590d21d9
commit 68d4b82756
36 changed files with 879 additions and 441 deletions

View File

@@ -0,0 +1,46 @@
import {Component, OnInit} from '@angular/core';
import {UserData} from "../../interface/user";
import {AuthService} from "../../services/auth.service";
import {ApiService} from "../../services/api.service";
import {NgbDatepicker, NgbDateStruct} from "@ng-bootstrap/ng-bootstrap";
import {FormsModule} from "@angular/forms";
import {NgIf} from "@angular/common";
import {Router} from "@angular/router";
@Component({
selector: 'app-dashboard',
standalone: true,
imports: [
NgbDatepicker,
FormsModule,
NgIf
],
templateUrl: './dashboard.component.html',
styleUrl: './dashboard.component.scss'
})
export class DashboardComponent implements OnInit {
isLoggedIn = false;
userData: UserData = {
uuid: null,
username: null,
email: null,
createdAt: null
}
constructor(private authService: AuthService, private apiService: ApiService, private router: Router) {
}
ngOnInit(): void {
if (this.authService.isLoggedIn()) {
this.apiService.getCurrentUser().subscribe(res => {
this.userData = res;
this.isLoggedIn = true;
})
} else {
this.router.navigate(['/login']).then();
}
}
}