import {Component, inject, OnInit, signal} from '@angular/core'; import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms"; import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzFormControlComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {DeliverersService, GetDelivererDto} from "../../services/api"; import {firstValueFrom} from "rxjs"; import {NzNotificationService} from "ng-zorro-antd/notification"; @Component({ selector: 'app-deliverer-choice', imports: [ FormsModule, NzColDirective, NzFlexDirective, NzFormControlComponent, NzFormLabelComponent, NzOptionComponent, NzRowDirective, NzSelectComponent, ReactiveFormsModule ], templateUrl: './deliverer-choice.html', styleUrl: './deliverer-choice.css', }) export class DelivererChoice implements OnInit { private deliverersService = inject(DeliverersService); private notificationService = inject(NzNotificationService); choiceDelivererForm: FormGroup = new FormGroup({ delivererId: new FormControl(null, Validators.required), }); deliverers = signal([]); async ngOnInit() { try { const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint()); this.deliverers.set(deliverers); } catch { this.notificationService.error('Erreur', 'Erreur lors de l\'affichage des livreurs'); } } }