import { ProjectViewModel } from '../projects/project.presenter.model';
import { Project } from '@app/domain/projects/project.model';
import { environment } from '@env/environment';

export class ProjectPresenter {
  toViewModel(project: Project): ProjectViewModel {
    const fichier = project.fichier
      ? `${environment.baseUrl}/api/files/projets/${project.id}/${project.fichier}`
      : `https://api.dicebear.com/9.x/shapes/svg?seed=${project.nom}`;
    return {
      id: project.id,
      created: project.created,
      updated: project.updated,
      nom: project.nom,
      lien: project.lien,
      description: project.description ?? 'Aucune description disponible.',
      fichier,
      utilisateur: project.utilisateur,
    };
  }

  toViewModels(projects: Project[]): ProjectViewModel[] {
    return projects.map(this.toViewModel);
  }

  private formatFichier(project: Project) {}
}
