import { Component, input, OnChanges, SimpleChanges } from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import { ProjectItemComponent } from '@app/shared/components/project-item/project-item.component';
import { ProjectFacade } from '@app/adapters/projects/project.facade';

@Component({
  selector: 'app-project-list',
  standalone: true,
  imports: [ProjectItemComponent],
  templateUrl: './project-list.component.html',
  styleUrl: './project-list.component.scss',
})
@UntilDestroy()
export class ProjectListComponent implements OnChanges {
  userProjectId = input.required<string>({});

  private readonly projectFacade = new ProjectFacade();

  protected projects = this.projectFacade.projects;

  ngOnChanges(changes: SimpleChanges) {
    this.projectFacade.load(this.userProjectId());
  }
}
