This commit is contained in:
styve Lioumba
2025-11-20 14:37:41 +01:00
parent dd77e3d023
commit 06979b79e3
21 changed files with 205 additions and 152 deletions

View File

@@ -1,4 +1,4 @@
import { Component, computed, inject, OnInit, signal } from '@angular/core';
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';
@@ -11,6 +11,8 @@ import { MyProfileProjectListComponent } from '@app/shared/components/my-profile
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',
@@ -24,7 +26,9 @@ import { ProfileFacade } from '@app/ui/profiles/profile.facade';
MyProfileUpdateFormComponent,
PdfViewerComponent,
UpperCasePipe,
LoadingComponent,
],
providers: [UserFacade],
templateUrl: './my-profile.component.html',
styleUrl: './my-profile.component.scss',
})
@@ -33,17 +37,14 @@ export class MyProfileComponent implements OnInit {
protected readonly environment = environment;
protected menu = signal<string>('home');
protected myProfileQrCode = `${environment.production}`;
protected location = inject(Location);
protected readonly route = inject(ActivatedRoute);
protected extraData: { user: User } = this.route.snapshot.data['user'];
protected user = computed(() => {
if (this.extraData != undefined) return this.extraData.user;
return {} as 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;
@@ -51,7 +52,9 @@ export class MyProfileComponent implements OnInit {
protected readonly error = this.profileFacade.error;
ngOnInit(): void {
this.myProfileQrCode = `${this.myProfileQrCode}/profiles/${this.user().id}`;
this.profileFacade.loadOne(this.user().id);
if (this.extraData != undefined) {
this.profileFacade.loadOne(this.extraData.user.id);
this.userFacade.loadOne(this.extraData.user.id);
}
}
}