get all start

This commit is contained in:
2025-11-27 17:51:38 +01:00
parent 20ddd65dc3
commit 265acb7ba9
15 changed files with 116 additions and 4 deletions

View File

@@ -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>

View File

@@ -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);
}
}