54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
import { Title } from '@angular/platform-browser';
|
|
import { RouterLink } from '@angular/router';
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
import { MatCardModule } from '@angular/material/card';
|
|
import { MatDividerModule } from '@angular/material/divider';
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
|
|
import { Subscription } from 'rxjs';
|
|
|
|
import { Errors, User } from 'src/app/core/models';
|
|
import { UserService } from 'src/app/core/services';
|
|
import { ListErrorsComponent } from 'src/app/components/shared';
|
|
|
|
@Component({
|
|
standalone: true,
|
|
imports: [
|
|
RouterLink,
|
|
MatButtonModule, MatCardModule, MatDividerModule, MatIconModule,
|
|
ListErrorsComponent
|
|
],
|
|
selector: 'app-profile',
|
|
templateUrl: './profile.component.html',
|
|
styleUrl: './profile.component.scss'
|
|
})
|
|
export class ProfileComponent implements OnInit, OnDestroy {
|
|
private _user: Subscription = new Subscription();
|
|
title = 'Mon compte';
|
|
bannerTitle = '';
|
|
user: Partial<User> = {} as Partial<User>;
|
|
errors: Errors = { errors: {} };
|
|
btnSettingsTitle = 'Paramètres';
|
|
|
|
constructor(
|
|
private titleService: Title,
|
|
private userService: UserService
|
|
) { }
|
|
|
|
ngOnInit() {
|
|
this.titleService.setTitle(`Ad Astra - ${this.title}`);
|
|
Object.assign(this.user, this.userService.getCurrentUser());
|
|
if (this.user.username) {
|
|
this.bannerTitle = `@${this.user.username}`;
|
|
} else {
|
|
this.bannerTitle = `${this.user.firstname} ${this.user.lastname}`;
|
|
}
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this._user.unsubscribe();
|
|
}
|
|
|
|
}
|