connect front to back
This commit is contained in:
@@ -1,24 +1,49 @@
|
||||
import {Component, input} from '@angular/core';
|
||||
import {AuthorInfo} from "../../interfaces/author.interfaces";
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import {Modal} from "../modal/modal";
|
||||
import {NzButtonComponent} from "ng-zorro-antd/button";
|
||||
import {NzCardComponent, NzCardMetaComponent} from "ng-zorro-antd/card";
|
||||
import {UpdateAuthor} from "../update-author/update-author";
|
||||
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,
|
||||
NzCardComponent,
|
||||
UpdateAuthor,
|
||||
NzCardMetaComponent
|
||||
NzTableComponent,
|
||||
UpdateLoan
|
||||
],
|
||||
templateUrl: './author-card.html',
|
||||
styleUrl: '../book-card/book-card.css',
|
||||
styleUrl: './author-card.css',
|
||||
})
|
||||
export class AuthorCard {
|
||||
authorInfo = input.required<AuthorInfo>();
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user