52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import {Component, inject, OnInit, signal} from '@angular/core';
|
|
import {Modal} from "../modal/modal";
|
|
import {NzButtonComponent} from "ng-zorro-antd/button";
|
|
import {AuthorsService, GetAuthorDto} from "../../services/api";
|
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
|
import {firstValueFrom} from "rxjs";
|
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
|
import {UpdateLoan} from "../update-loan/update-loan";
|
|
|
|
@Component({
|
|
selector: 'app-author-card',
|
|
imports: [
|
|
Modal,
|
|
NzButtonComponent,
|
|
NzTableComponent,
|
|
UpdateLoan
|
|
],
|
|
templateUrl: './author-card.html',
|
|
styleUrl: './author-card.css',
|
|
})
|
|
export class AuthorCard implements OnInit {
|
|
private authorsService = inject(AuthorsService);
|
|
private notificationService = inject(NzNotificationService)
|
|
|
|
authors = signal<GetAuthorDto[]>([]);
|
|
|
|
authorsLoading = signal<boolean>(false);
|
|
|
|
async ngOnInit() {
|
|
await this.fetchauthors();
|
|
}
|
|
|
|
async fetchauthors() {
|
|
this.authorsLoading.set(true)
|
|
|
|
try {
|
|
const authors = await firstValueFrom(this.authorsService.getAllAuthorsEndpoint());
|
|
|
|
} catch (e) {
|
|
this.notificationService.error(
|
|
'Erreur',
|
|
'Erreur de communication avec l\'API'
|
|
)
|
|
}
|
|
this.authorsLoading.set(false)
|
|
}
|
|
|
|
delete() {
|
|
return
|
|
}
|
|
}
|