Fixed projects not showing on login

This commit is contained in:
Marta Borgia Leiva 2026-02-11 11:56:40 +01:00
parent 7202ed8806
commit cd041d04cd
6 changed files with 37 additions and 29 deletions

View file

@ -1,4 +1,4 @@
import { Component, inject } from '@angular/core';
import { Component, inject, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Router } from '@angular/router';
import { AuthService } from '../../services/auth.service';
@ -12,12 +12,14 @@ import { Project } from '../../models/projects.models';
templateUrl: './home.component.html',
styleUrl: './home.component.css',
})
export class HomeComponent {
export class HomeComponent implements OnInit {
protected authService = inject(AuthService);
private router = inject(Router);
protected get projectList(): Project[] {
return this.authService.currentUser()?.projects ?? [];
protected projects: Project[] = [];
ngOnInit(): void {
this.projects = this.authService.currentUser()?.projects ?? [];
}
onCreateProject() {
@ -27,4 +29,5 @@ export class HomeComponent {
trackByProjectId(_index: number, project: Project): number {
return project.id;
}
}