import {Component, inject, signal} from '@angular/core'; import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzColDirective} from "ng-zorro-antd/grid"; import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzDatePickerComponent} from "ng-zorro-antd/date-picker"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {DeliverersService, GetDelivererDto} from "../../services/api"; import {NzNotificationService} from "ng-zorro-antd/notification"; import {firstValueFrom} from "rxjs"; @Component({ selector: 'app-deliverery-note-form', imports: [ NzFormItemComponent, NzFormLabelComponent, NzFormControlComponent, NzColDirective, NzFlexDirective, NzFormDirective, ReactiveFormsModule, NzDatePickerComponent, NzSelectComponent, NzOptionComponent ], templateUrl: './deliverery-note-form.html', styleUrl: './deliverery-note-form.css', }) export class DelivereryNoteForm { deliveryNoteForm: FormGroup = new FormGroup({ deliverer: new FormControl(null,[Validators.required]), expeditionDate: new FormControl(null,[Validators.required]), estimatedDate: new FormControl(null), realDeliveryDate: new FormControl(null) }) private deliverersService = inject(DeliverersService); private notificationService = inject(NzNotificationService); deliverers = signal([]); async fetchDeliverers() { try { const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint()); this.deliverers.set(deliverers); } catch (e) { this.notificationService.error('Erreur', 'Impossible de récupérer les transporteurs'); } } async ngOnInit() { await this.fetchDeliverers(); } filter(input: string, option: any) { return option.nzLabel.toLowerCase().includes(input.toLowerCase()); } }