get all start
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<div class="card">
|
||||
<div nz-row [nzGutter]="10" style="gap: 30px">
|
||||
@for (customer of customers(); track customer.id)
|
||||
{
|
||||
<nz-card style="width:400px;">
|
||||
<h2 style="text-align: center; font-weight: bold">Utilisateur n°{{ customer.id }}</h2>
|
||||
<p>Nom/Prénom : {{ customer.name }} {{ customer.firstName }}</p>
|
||||
<p>Téléphone : {{ customer.phone }}</p>
|
||||
<p>Email : {{ customer.email }}</p>
|
||||
<p>Adresse : {{ customer.address }}</p>
|
||||
<p>Note : {{ customer.note }}</p>
|
||||
</nz-card>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
import {Component, inject, signal} from '@angular/core';
|
||||
import {Router} from "@angular/router";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
|
||||
@Component({
|
||||
selector: 'app-customers-get-all',
|
||||
imports: [],
|
||||
templateUrl: './customers-get-all.html',
|
||||
styleUrl: './customers-get-all.css',
|
||||
})
|
||||
export class CustomersGetAll {
|
||||
private customerService = inject(CustomersService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
|
||||
router = inject(Router);
|
||||
|
||||
customers = signal<GetCustomerDto[]>([]);
|
||||
customersLoading = signal<boolean>(false);
|
||||
async ngOnInit() {
|
||||
await this.fetchCustomers();
|
||||
}
|
||||
|
||||
async fetchCustomers() {
|
||||
this.customersLoading.set(true);
|
||||
try {
|
||||
const customer = await firstValueFrom(this.customerService.getAllCustomersEndpoint())
|
||||
this.customers.set(customer)
|
||||
} catch (e)
|
||||
{
|
||||
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API');
|
||||
}
|
||||
|
||||
this.customersLoading.set(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user