project refactoring en clean archi
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="max-w-4xl max-lg:max-w-2xl max-sm:max-w-sm mx-auto">
|
||||
<h2 class="text-2xl font-bold text-gray-800 mb-8">Explorer les projets</h2>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
@for (project of projects; track project) {
|
||||
@for (project of projects(); track project) {
|
||||
<app-project-item [project]="project" />
|
||||
} @empty {
|
||||
<p>Aucun projet</p>
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { Component, inject, Input, OnInit } from '@angular/core';
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { UntilDestroy } from '@ngneat/until-destroy';
|
||||
import { ProjectItemComponent } from '@app/shared/components/project-item/project-item.component';
|
||||
import { JsonPipe } from '@angular/common';
|
||||
import { ProjectService } from '@app/core/services/project/project.service';
|
||||
import { Project } from '@app/shared/models/project';
|
||||
import { ProjectFacade } from '@app/ui/projects/project.facade';
|
||||
|
||||
@Component({
|
||||
selector: 'app-project-list',
|
||||
standalone: true,
|
||||
imports: [ProjectItemComponent, JsonPipe],
|
||||
imports: [ProjectItemComponent],
|
||||
templateUrl: './project-list.component.html',
|
||||
styleUrl: './project-list.component.scss',
|
||||
})
|
||||
@@ -16,13 +14,11 @@ import { Project } from '@app/shared/models/project';
|
||||
export class ProjectListComponent implements OnInit {
|
||||
@Input({ required: true }) userProjectId = '';
|
||||
|
||||
protected readonly projectService = inject(ProjectService);
|
||||
private readonly projectFacade = new ProjectFacade();
|
||||
|
||||
protected projects: Project[] = [];
|
||||
protected projects = this.projectFacade.projects;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.projectService
|
||||
.getProjectByUserId(this.userProjectId)
|
||||
.subscribe((value) => (this.projects = value));
|
||||
this.projectFacade.load(this.userProjectId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user