Files
trouvetonprofile/src/app/routes/my-profile/my-profile.component.ts
styve Lioumba 06979b79e3 refacto
2025-11-20 14:37:41 +01:00

61 lines
2.4 KiB
TypeScript

import { Component, inject, OnInit, signal } from '@angular/core';
import { ActivatedRoute, RouterOutlet } from '@angular/router';
import { User } from '@app/domain/users/user.model';
import { Location, UpperCasePipe } from '@angular/common';
import { UntilDestroy } from '@ngneat/until-destroy';
import { environment } from '@env/environment';
import { ChipsComponent } from '@app/shared/components/chips/chips.component';
import { ReseauxComponent } from '@app/shared/components/reseaux/reseaux.component';
import { UpdateUserComponent } from '@app/shared/features/update-user/update-user.component';
import { MyProfileProjectListComponent } from '@app/shared/components/my-profile-project-list/my-profile-project-list.component';
import { MyProfileUpdateFormComponent } from '@app/shared/components/my-profile-update-form/my-profile-update-form.component';
import { PdfViewerComponent } from '@app/shared/features/pdf-viewer/pdf-viewer.component';
import { ProfileFacade } from '@app/ui/profiles/profile.facade';
import { UserFacade } from '@app/ui/users/user.facade';
import { LoadingComponent } from '@app/shared/components/loading/loading.component';
@Component({
selector: 'app-my-profile',
standalone: true,
imports: [
ChipsComponent,
ReseauxComponent,
UpdateUserComponent,
MyProfileProjectListComponent,
RouterOutlet,
MyProfileUpdateFormComponent,
PdfViewerComponent,
UpperCasePipe,
LoadingComponent,
],
providers: [UserFacade],
templateUrl: './my-profile.component.html',
styleUrl: './my-profile.component.scss',
})
@UntilDestroy()
export class MyProfileComponent implements OnInit {
protected readonly environment = environment;
protected menu = signal<string>('home');
protected location = inject(Location);
protected readonly route = inject(ActivatedRoute);
protected extraData: { user: User } = this.route.snapshot.data['user'];
private readonly userFacade = inject(UserFacade);
protected user = this.userFacade.user;
protected readonly userLoading = this.userFacade.loading;
private readonly profileFacade = new ProfileFacade();
protected profile = this.profileFacade.profile;
protected readonly loading = this.profileFacade.loading;
protected readonly error = this.profileFacade.error;
ngOnInit(): void {
if (this.extraData != undefined) {
this.profileFacade.loadOne(this.extraData.user.id);
this.userFacade.loadOne(this.extraData.user.id);
}
}
}