32 lines
963 B
TypeScript
32 lines
963 B
TypeScript
import {Component, inject, OnInit, signal} from '@angular/core';
|
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
|
import {GetUserDto, UserService} from "../../services/api";
|
|
import {firstValueFrom} from "rxjs";
|
|
|
|
@Component({
|
|
selector: 'app-profil',
|
|
imports: [],
|
|
templateUrl: './profil.html',
|
|
styleUrl: './profil.css',
|
|
})
|
|
export class Profil implements OnInit {
|
|
private notificationService = inject(NzNotificationService);
|
|
private userService = inject(UserService);
|
|
|
|
user = signal<GetUserDto>({});
|
|
|
|
async ngOnInit() {
|
|
try {
|
|
const user = await firstValueFrom(this.userService.getUserEndpoint());
|
|
this.user.set(user);
|
|
} catch {
|
|
this.notificationService.error('Erreur', 'Impossible de charger l\'utilisateur');
|
|
}
|
|
}
|
|
|
|
getInitial(name: string): string {
|
|
if (!name || name.trim() === '') return '?';
|
|
return name[0].toUpperCase();
|
|
}
|
|
}
|