Staff PT1
This commit is contained in:
@@ -1,16 +1,40 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Component, inject, signal} from '@angular/core';
|
||||
import {StaffCardForm} from "./staff-card-form/staff-card-form";
|
||||
import {StaffGetAll} from "./staff-get-all/staff-get-all";
|
||||
import {NzRowDirective} from "ng-zorro-antd/grid";
|
||||
import {GetProviderDto, GetStaffDto, ServiceprovidersService, StaffsService} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {Router} from "@angular/router";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-staff',
|
||||
imports: [
|
||||
StaffCardForm,
|
||||
StaffGetAll
|
||||
],
|
||||
imports: [StaffCardForm, StaffGetAll, NzRowDirective,],
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user