get all customers done
This commit is contained in:
@@ -2,14 +2,8 @@
|
||||
<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>
|
||||
<!-- Passage de la donnée du parent vers l'enfant + signal à émettre -->
|
||||
<app-get-all-customers-card [customer]="customer" (triggerEdited)="fetchCustomers()" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,22 +1,28 @@
|
||||
import {Component, inject, signal} from '@angular/core';
|
||||
import {Router} from "@angular/router";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import {CustomersService, GetCustomerDto} from "../../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {ReactiveFormsModule} from "@angular/forms";
|
||||
import {NzFormModule} from "ng-zorro-antd/form";
|
||||
import {NzSpaceComponent} from "ng-zorro-antd/space";
|
||||
import {GetAllCustomersCard} from "../get-all-customers-card/get-all-customers-card";
|
||||
|
||||
@Component({
|
||||
selector: 'app-customers-get-all',
|
||||
imports: [],
|
||||
imports: [ReactiveFormsModule, NzFormModule, GetAllCustomersCard, GetAllCustomersCard],
|
||||
templateUrl: './customers-get-all.html',
|
||||
styleUrl: './customers-get-all.css',
|
||||
})
|
||||
export class CustomersGetAll {
|
||||
private customerService = inject(CustomersService);
|
||||
private customersService = inject(CustomersService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
|
||||
router = inject(Router);
|
||||
|
||||
customers = signal<GetCustomerDto[]>([]);
|
||||
customersLoading = signal<boolean>(false);
|
||||
|
||||
async ngOnInit() {
|
||||
await this.fetchCustomers();
|
||||
}
|
||||
@@ -24,10 +30,9 @@ export class CustomersGetAll {
|
||||
async fetchCustomers() {
|
||||
this.customersLoading.set(true);
|
||||
try {
|
||||
const customer = await firstValueFrom(this.customerService.getAllCustomersEndpoint())
|
||||
this.customers.set(customer)
|
||||
} catch (e)
|
||||
{
|
||||
const customers = await firstValueFrom(this.customersService.getAllCustomerEndpoint())
|
||||
this.customers.set(customers)
|
||||
} catch (e) {
|
||||
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user