2024-09-17 06:50:34 +00:00
|
|
|
import { Component } from '@angular/core';
|
2024-10-16 10:13:13 +00:00
|
|
|
import { AuthService } from '../../../../cores/services/auth.service';
|
2024-11-05 22:42:46 +00:00
|
|
|
import { Router, RouterModule } from '@angular/router';
|
2024-10-16 10:13:13 +00:00
|
|
|
import { ToastrService } from 'ngx-toastr';
|
2024-09-17 06:50:34 +00:00
|
|
|
|
2024-11-05 22:42:46 +00:00
|
|
|
|
2024-09-17 06:50:34 +00:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-sidebar',
|
|
|
|
|
standalone: true,
|
2024-11-05 22:42:46 +00:00
|
|
|
imports: [RouterModule],
|
2024-09-17 06:50:34 +00:00
|
|
|
templateUrl: './sidebar.component.html',
|
2024-10-16 10:13:13 +00:00
|
|
|
styleUrls: ['./sidebar.component.scss']
|
2024-09-17 06:50:34 +00:00
|
|
|
})
|
|
|
|
|
export class SidebarComponent {
|
2024-10-16 10:13:13 +00:00
|
|
|
fullName: string | null = null;
|
|
|
|
|
avatar: string | null = null;
|
2024-09-17 06:50:34 +00:00
|
|
|
|
2024-10-16 10:13:13 +00:00
|
|
|
constructor(private authService: AuthService, private router: Router, private toast: ToastrService) {
|
|
|
|
|
this.fullName = this.authService.getUserFullName();
|
|
|
|
|
this.avatar = this.authService.getAvatar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onLogout(): void {
|
|
|
|
|
this.authService.logout().subscribe(
|
|
|
|
|
() => {
|
|
|
|
|
this.router.navigate(['/auth']);
|
|
|
|
|
this.toast.success('Logout successful');
|
|
|
|
|
},
|
|
|
|
|
(error: any) => {
|
|
|
|
|
this.toast.error(error.error.message);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-09-17 06:50:34 +00:00
|
|
|
}
|