54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import {Component, inject, OnInit, signal} from '@angular/core';
|
|
import {DatePipe} from "@angular/common";
|
|
import {Modal} from "../modal/modal";
|
|
import {NzButtonComponent} from "ng-zorro-antd/button";
|
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
|
import {UpdateLoan} from "../update-loan/update-loan";
|
|
import {GetLoanDto, LoansService} from "../../services/api";
|
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
|
import {firstValueFrom} from "rxjs";
|
|
|
|
@Component({
|
|
selector: 'app-loan-table',
|
|
imports: [
|
|
DatePipe,
|
|
Modal,
|
|
NzButtonComponent,
|
|
NzTableComponent,
|
|
UpdateLoan
|
|
],
|
|
templateUrl: './loan-table.html',
|
|
styleUrl: './loan-table.css',
|
|
})
|
|
export class LoanTable implements OnInit {
|
|
private loansService = inject(LoansService);
|
|
private notificationService = inject(NzNotificationService)
|
|
|
|
loans = signal<GetLoanDto[]>([]);
|
|
|
|
loansLoading = signal<boolean>(false);
|
|
|
|
async ngOnInit() {
|
|
await this.fetchloans();
|
|
}
|
|
|
|
async fetchloans() {
|
|
this.loansLoading.set(true)
|
|
|
|
try {
|
|
const loans = await firstValueFrom(this.loansService.getAllLoanEndpoint())
|
|
|
|
} catch (e) {
|
|
this.notificationService.error(
|
|
'Erreur',
|
|
'Erreur de communication avec l\'API'
|
|
)
|
|
}
|
|
this.loansLoading.set(false)
|
|
}
|
|
|
|
delete() {
|
|
return
|
|
}
|
|
}
|