41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import {Component, inject, signal} from '@angular/core';
|
|
import {NzRowDirective} from "ng-zorro-antd/grid";
|
|
import {GetStaffDto, StaffsService} from "../../services/api";
|
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
|
import {Router} from "@angular/router";
|
|
import {firstValueFrom} from "rxjs";
|
|
import {CreateStaffModal} from "./create-staff-modal/create-staff-modal";
|
|
import {StaffCard} from "./staff-card/staff-card";
|
|
|
|
@Component({
|
|
selector: 'app-staff',
|
|
imports: [NzRowDirective, CreateStaffModal, StaffCard,],
|
|
templateUrl: './staff.html',
|
|
styleUrl: './staff.css',
|
|
})
|
|
export class Staff {
|
|
private staffsService = inject(StaffsService);
|
|
private notificationService = inject(NzNotificationService)
|
|
|
|
router = inject(Router);
|
|
|
|
staffs = signal<GetStaffDto[]>([]);
|
|
staffsLoading = signal<boolean>(false);
|
|
|
|
async ngOnInit() {
|
|
await this.fetchStaff();
|
|
}
|
|
|
|
async fetchStaff() {
|
|
this.staffsLoading.set(true);
|
|
try {
|
|
const staff = await firstValueFrom(this.staffsService.getAllStaffsEndpoint())
|
|
this.staffs.set(staff)
|
|
} catch (e) {
|
|
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API');
|
|
}
|
|
|
|
this.staffsLoading.set(false);
|
|
}
|
|
}
|